Copy query parameter

andyrew30

Registered User.
Local time
Today, 15:23
Joined
Feb 3, 2014
Messages
16
Hi All

So the question I have is that I am trying to copy the parameter value that is entered to a variable so that it can be used to run other queries without typing it in over and over. Once my form is finished it will run 4 queries, and the current setup is that I would have to retype the parameter each time.

Thanks!
 
I would have the user enter the parameter on the form, and let the queries all get it from there.
 
ok. I will try that. I think that may work.

Thanks
 
No problem, post back if you get stuck.
 
So I set it up to pull from the form as you had suggested. But I can't figure out the code to get the reports to open based on a saved variable from the form. I am currently trying this: Where ScannerTxt is my input box.



Private Sub Command5_Click()

Dim stPartNum As String
Dim stDocName As String
Dim stCond As String

Set stPartNum = Me.ScannerTxt
stCond = "[SAP Product PN] = '" & stPartNum & "'"
stDocName = "RptPackingList"
'open & print report
x = acApp.DoCmd.OpenReport(stDocName, acPreview, , WhereCondition:=stCond)




End Sub

Thanks
 
Try:

DoCmd.OpenReport "RptPackingList", acPreview, , "[SAP Product PN] = '" & Me.ScannerTxt & "'"
 
Happy to help! I don't bother setting variables if I'm only going to use the value once.
 
I ran into what I believe will be the last major error in this program and it's still along the lines of the scannertxt. Essentially i am attaching a dlookup function to pull the value of one of the columns in a table when a parameter is entered.


This is currently what my dlookup code looks like, where control plan # is the name of the column I am trying to pull the data from, controlplanlist is the name of the table, and SAP Product PN is the number that is passed through the query.


F01U = DLookup("[Control Plan #]", "ControlPlanList", "SAP Product PN = Me.ScannerTxt")
 
Due to the inadvisable spaces, the field name needs to be bracketed.
 

Users who are viewing this thread

Back
Top Bottom