Using 2 combo boxes to populate a subform

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have 2 combo boxes. One contains a site location, the other the date. I'm
trying to get it so when I select the location and the date, the subform will
populate with the employee's name, location, date, etc. to track time-off.

I have the record source code for the sub-form

SELECT [tbTime-Off].[Employee Name], [tbTime-Off].Date,
[tbTime-Off].Location, [tbTime-Off].Coverage
FROM [tbTime-Off]
WHERE ((([tbTime-Off].Date)=[Forms]![frmLocation]![Combo2]) AND
(([tbTime-Off].Location)=[Forms]![frmLocation]![Combo1]));


I also have a command button, with and OnClick of:


Private Sub Command00_Click()

Me.PTO.Requery

End Sub


But for some reason I cannot get the sub-form to populate.
 
Try this on the combobox's AfterUpdate event:

strRS = "SELECT [Employee Name], Date, Location, Coverage FROM [tbTime-Off]
WHERE ((Date=#" & [Forms]![frmLocation]![Combo2] & "#) AND (Location='" &
[Forms]![frmLocation]![Combo1] & "'));"

Me.SubForm.Form.RecordSource = strRS

strRS is supposed to be one long line so if it is broken up in the posting,
reassemble it or add line continuation characters.
I have 2 combo boxes. One contains a site location, the other the date. I'm
trying to get it so when I select the location and the date, the subform will
populate with the employee's name, location, date, etc. to track time-off.

I have the record source code for the sub-form

SELECT [tbTime-Off].[Employee Name], [tbTime-Off].Date,
[tbTime-Off].Location, [tbTime-Off].Coverage
FROM [tbTime-Off]
WHERE ((([tbTime-Off].Date)=[Forms]![frmLocation]![Combo2]) AND
(([tbTime-Off].Location)=[Forms]![frmLocation]![Combo1]));

I also have a command button, with and OnClick of:

Private Sub Command00_Click()

Me.PTO.Requery

End Sub

But for some reason I cannot get the sub-form to populate.
 
Back
Top