can someone suggest me how to put a look up. i have a look up command button and if i want to click it, i want to pop up a window that will display all the departments of the company.
thanks
Printable View
can someone suggest me how to put a look up. i have a look up command button and if i want to click it, i want to pop up a window that will display all the departments of the company.
thanks
Code:This should get you started:
1. Requirements 2nd form/listbox/command button
On form2 call the listbox lstDept, the command
button cmdReturn
2. A File as source of your departments (c:\departments.txt)
Assuming there are not a lot of departments and all you
want is departments I would use a text file.
'this is the code for Form1
Option Explicit
Private Sub cmdLookUp_Click()
Form1.Hide
Form2.Show
End Sub
'this is the code for Form2
Option Explicit
Private Sub cmdReturn_Click()
Form2.Hide
Form1.Show
End Sub
Private Sub Form_Load()
On Error GoTo quit:
Dim myFile As String, myVar As String
Dim intNum As Integer
myFile = "C:\departments.txt"
intNum = FreeFile
Open myFile For Input As intNum
While Not EOF(intNum)
Input #intNum, myVar
lstDept.AddItem myVar
Wend
Close #intNum
quit:
MsgBox "you need to write an error routine for the sub"
End Sub
Private Sub lstDept_Click()
MsgBox "You have selected " & lstDept.Text
End Sub
In addition to what HeSaidJoe says, you can put the 2nd listbox on top of the current listbox and set the visible and forground properties to false.
You should be able to move the 2nd box around during runtime, such that the top edge of the box allows the selected item. You use the "Top" and "Left" properties for this.
Good Luck
DerFarm