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




Reply With Quote