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

Opening Specific Records in a Form (Form to Form) 1

Status
Not open for further replies.

MattMeat

Programmer
Nov 6, 2001
38
0
0
US
Hello,

I have two forms that I am working with. One is a form in datasheet view, and the other is a WorkOrderEntry in form view. In the datasheet, there is a specific column called "WorkOrderNo". This column contains the numbers I would like to use to open the other form, with the correct record showing. Basically, I need the corresponding WorkorderEntry RECORD to open on double click of the number in datasheet view. I can already toggle between the two forms by using macros. I just can't get the correct corresponding record to come up. I would also like to know if there is a better way to go about solving this problem,

Thank You Very Much,
Matt
 
Open the datasheet in the design view. right click on WorkOrderNo, select properties, event, double click, code builder.
Paste this in.

Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmWorkOrderEntry"
stLinkCriteria = "[WorkOrderNo]=" & Me![WorkOrderNo]
DoCmd.Close
DoCmd.OpenForm stDocName, , , stLinkCriteria

This will replace your macro to open the form. What this does is applies a filter when the form is opened. This means that you will have only the one record available through the form until the filter is reset. You can reset the filter through the menu bar. Hope this helps, if you need more code let me know.
 
James79,

Thank you so much for this! It worked perfectly. I'm sure you'll be seeing me around this site again. Keep up the great work! I really appreciate it and I'm sure others do too!

MattMeat
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top