Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Subform field referencing master form field

Status
Not open for further replies.

sippa

Technical User
Sep 21, 2009
1
US
I have a timesheet I am working on. On load the master form calculates the dates for the beginnng and end of the prior week (but this can be overridden by manually entering dates). When the user selects the employee, the subform comes up with their timesheet and goes to a new record.

I want the timesheet date entries to be limited to the beginning and ending dates as defined by the master form, but I can't figure out how to reference those fields from the subform. Access keeps telling me that it can't find the object. How do I reference a field in the master form from the subform. Me. doesn't work and I haven't been able to figure out using the form name (maybe because it is still dirty?)

Also I tried using "If [subform workdate] Between" and Access says it wants to see "If Then" How do I write an If statement using Between?

This database has been a work in process for 4 years, and I am finally figuring out Visual Basic, but it is one trial after another. I am hoping that you guys can make my life easier. Thanks.
 
Me.Parent will reference the main form from the subform, or if you wish to reference the form in a filetr, use something like:

Forms!MainFormName!txtDateStart

The best bet is probably to build an SQL statement on the main form that includes the date range you want and set the recordsource of the subform to the SQL statement.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top