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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form Help

Status
Not open for further replies.

ddmtn546

Technical User
Dec 20, 2000
38
US
Good Day All,
I am struggling with forms, being somewhat new to Access.
Description: I have a Maintenance Database. The 1st form is based from the table "Customer". It displays customers using a primary keyed "CustomerID" field. The 2nd form is based from the table "Workorders". The primary key field is "WorkorderID". The 2nd field in "Workorders" is "CustomerID".
Problem: How do I force the "Workorders" form to open to the current open record of the "Customer" form?
Thanks in advance.
 
add a "Where" condition to the OpenForm command, and reference the control that contains the field CustomerID. If CustomerID is a numeric field there is no need to use delimiters around the control name, but if the field is a text field or date field then you'd need to add delimiters( "'" equates to double quote, single quote, double quote

Numeric Field
DoCmd.OpenForm Form2Name, , , "[CustomerID] = " & Forms!Form1Name.CustomerIDControl

Text Field
DoCmd.OpenForm Form2Name, , , "[CustomerID] = '" & Forms!Form1Name.CustomerIDControl & "'"

Date Field
DoCmd.OpenForm Form2Name, , , "[CustomerID] = #" & Forms!Form1Name.CustomerIDControl & "#"

You might want to look into SubForms, they might be an avenue you wish to explore.

PaulF
 
Hey ddmtn646! If you are really new to Access then you need to explore the subform option. It does all of the code that PaulF described for you. There is a subform wizard in the toolbox in form design. Try it out!
Sera
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top