LearningEX
Board Regular
- Joined
- Mar 13, 2015
- Messages
- 208
hi all, the picture below is what i want to achieve. i want to be able to select a date from the date picker, then select a truck for that date as i may have two trucks out on that date, then based on the two criteria, i then want the information returned to the listboxes like the picture.
VBA Code:
Private Sub txtTourDate_AfterUpdate()
100: 'Check to see if value exists
101: If WorksheetFunction.CountIf(Sheet12.Range("C:C"), Me.txtTourDate.Value) = 0 Then
102: MsgBox "This date is Not Found"
103: Me.txtTourDate.Value = ""
104: Exit Sub
105: End If
106: 'Lookup values based on first control
107: With Me
108: .CboTrucks = Application.WorksheetFunction.VLookup(CLng(Me.txtTourDate), Sheet12.Range("Lookup"), 2, 0)
109: .Label3 = Application.WorksheetFunction.VLookup(CLng(Me.txtTourDate), Sheet12.Range("Lookup"), 14, 0)
110: .Label6 = Application.WorksheetFunction.VLookup(CLng(Me.txtTourDate), Sheet12.Range("Lookup"), 20, 0)
111: .Label10 = Application.WorksheetFunction.VLookup(CLng(Me.txtTourDate), Sheet12.Range("Lookup"), 23, 0)
112: .Label13 = Application.WorksheetFunction.VLookup(CLng(Me.txtTourDate), Sheet12.Range("Lookup"), 26, 0)
113:
114: End With
End Sub
VBA Code: