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

Retrieve and pass data

Status
Not open for further replies.

CFields

Programmer
Mar 1, 2001
6
US
I'm using a query on a form that you open to find a record, then I use a command button to put this information into a subform. The code works the first time opened and then stalls. You have to shut down the form and come back in for it to work again. This is my code, what am I missing or needing to add.
Private Sub Button48_Click()
On Error GoTo Err_Button48_Click

Dim docname As String
Dim LinkCriteria As String

docname = "Master Requisition Form"
LinkCriteria = "[STOCK] = Forms![View Inventory by Stock/TR/PO]![STOCK]"
DoCmd.OpenForm docname, , , LinkCriteria
DoCmd.GoToControl "MASTER REQUISITION SUB FORM"
DoCmd.GoToControl "TR"

DoCmd.FindRecord [Forms]![View Inventory by Stock/TR/PO]![TR]

Exit_Button48_Click:
Exit Sub
It's giving me a headache. Why does it work once and not consecutively. Please help and thank you in advance for your help.
C Fields
 
You're filtering the form with linkCriteria. Show the navigation buttons to see this. Cheap fix... add this right before Docmd.openform...:
DoCmd.Close acForm, "Master Requisition Form"
If you use an IsLoaded or IsOpen function you could focus on the loaded/open form and DoCmd.RunCommand acCmdRemoveFilterSort. Gord
ghubbell@total.net
 
That didn’t work. I have a button off The MR Form to open the query ran View Inventory Form then I have a select button they push to put that information onto the MR sub form. The code follows, remember the code works the first time but not consecutively.
MR FORM button
Dim docname As String
Dim LinkCriteria As String

docname = "View Inventory by Stock/TR/PO"
DoCmd.OpenForm docname, , , LinkCriteria
Later this same form closes it on exit from MR form
DoCmd.Close A_FORM, "View Inventory by Stock/TR/PO"

IN VIEW INVENTORY Form the select button
Dim docname As String
Dim LinkCriteria As String

docname = "Master Requisition Form"
LinkCriteria = "[STOCK] = Forms![View Inventory by Stock/TR/PO]![STOCK]"
DoCmd.OpenForm docname, , , LinkCriteria
DoCmd.GoToControl "MASTER REQUISITION SUB FORM"
DoCmd.GoToControl "TR"

DoCmd.FindRecord [Forms]![View Inventory by Stock/TR/PO]![TR]
It works the first time in. I tried your idea and I tried it several ways, but it didn’t do anything. I even tried ADD which didn’t work. Any more information to why this stopped working. I appreciate the help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top