Using 2 combo boxes to populate a subform

G

GEdwards

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.
 
K

kingston via AccessMonster.com

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top