help with listbox, please...
Here's my problem:
I'm opening a form called invdwg, when the form opens instead of having a button to click on to fill my text1, I need my text 1 to be filled upon opening of the form.
problem 2: when I click on my ok button after my listbox has been filled, the ok button acts like it's opening the file but does not until it is clicked again. WHY? I do not have DBLclick event anywhere in my code.
My code is listed below: Any assistance would be greatly appreciated.
Option Explicit
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
(ByVal hWND As Long, _
ByVal lpOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long
Private Const LB_FINDSTRINGEXACT = &H1A2
Private Const CB_FINDSTRINGEXACT = &H158
Private Const SW_SHOWNORMAL = 1
Private Const SW_SHOWMINIMIZED = 2
Private Const SW_SHOWMAXIMIZED As Long = 3
Private Sub BtnCancel_Click()
Text1.Text = ""
List1.Clear
End Sub
Private Sub BtnExit_Click()
End
End Sub
Private Sub Btnpartno_Click()
Dim strFile As String
Dim lngResult As Long
Dim strPath As String
List1.Clear
If RTrim(ThisForm.m2mpageframe1.Page1.txtfpartno.Value) <> "" Then
Text1.Text = RTrim(ThisForm.m2mpageframe1.Page1.txtfpartno.Value)
strFile = Dir("J:\Eimg\" & RTrim(ThisForm.m2mpageframe1.Page1.txtfpartno.Value) & "*.pdf")
Do While Not strFile = ""
Me.List1.AddItem strFile
strFile = Dir
Loop
Else
MsgBox "Please Enter Part Number!", vbExclamation
End If
End Sub
Sub btnok_click()
Dim strFile As String
Dim lngResult As Long
Dim strPath As String
Dim kind As String
lngResult = ShellExecute(0&, "Open", "J:\Eimg\" & Me.List1, 0&, 0&, LB_FINDSTRINGEXACT)
If lngResult <= 32 Then
MsgBox "Something went wrong.", vbExclamation
End If
End Sub

