filter subform by two criteria

hzeigler4

Registered User.
Local time
Yesterday, 20:24
Joined
Apr 18, 2007
Messages
42
Hi all. I have read tons of posts on here and cannot find exactly what I am looking for. I have a main form that contains a continuous subform. The main form has the user select and employee from a combo box and then has them enter a dtae. I would like to show only those records with that employee and the date entered when the user exits the date box. Then I would like the user to be able to add additonal records on the subform with the [DateWorked] field defaulting to the value in the date box on the main form. I am attaching my database. The main form in frmEmpHours and the subform is subfrmEmpHours. Any help would be greatly appreciated!!!!
 

Attachments

I don't have Access with me so, I cannot take a look at your database.
But, if your subform is linked to your form with DateWorked(LinkChildFields & LinkMasterFields), it would then filled the Date field with the default date and it can be changed without a problem.
If you don't want the user to change the date, just get rid of that field on the subform.
The same applies to the employee field.
 
I actually attached the wrong database. I am attaching the correct one. The subform child and master links is the empID. Can I add Date as well? This will allow them to add additional records in the subform using the date and emp id from the main form? Sorry but have only ever linked on one field before.
 
When the wizard ask you for these links, there is two options, «Choose from the list below» or «Create them yourself» (Translated from French; may be different in your version). By choosing «Create them yourself» you can link many fields manualy.
 
So I deleted my subform from the main form. Then re-added it using the wizard and defined my link fields as empID and DateWorked. It does not work. When I select an employee it shows all the records for that employee.(I do not want it to filter until they enter the date). Then when I enter the date of an existing record it still shows all the records with other dates. And when I add a record, it does not make the DateWorked = to what was entered on the main form. Here is what I did: frmEmpHours and subfrmEmpHours
 

Attachments

As I said earlier, I don't have Access with me, if no one else answers today, I'll take a look at it tomorrow.
Good luck!

Edit:
You would have to do a refresh of the subform after the change has been made in the date field.
 
So I deleted my subform from the main form. Then re-added it using the wizard and defined my link fields as empID and DateWorked. It does not work. When I select an employee it shows all the records for that employee.(I do not want it to filter until they enter the date). Then when I enter the date of an existing record it still shows all the records with other dates. And when I add a record, it does not make the DateWorked = to what was entered on the main form. Here is what I did: frmEmpHours and subfrmEmpHours

If you linked the sub to the main as Newman suggested then the sub should follow the main form. You might have to put a requery statement in the AfterUpdate Event of the date enter field. Like this

[Forms]![frmEmpHours]![subfrmEmpHours].Requery
 
I added the requery and tried assigning the DateWorked field on the sub to the DateWorked field on the main and it still does not filter based upon the date entered. Any other ideas?
 

Attachments

ok i finally got it!! Thanks so much!!! I thought I had it linkin on empid and date but for some reason it was not. That works lik a charm!!!!!!!!!
 

Users who are viewing this thread

Back
Top Bottom