datahunter said:
i checked my query and yes the field does exist.... right now my command
button after click i gt a popup box asking for the value of customer_ID
instead of getting from my current form where button is located. code is
as
follows:
Me.refresh
DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenReport "contract", acViewPreview, , "[customer_ID]=" &
Me.[customer_ID]
While in the code editor, do a debug->compile...make sure your code
compiles....
further, while in the forms design mode...do a view-> field list...do you
see customer_id in the field list?
You can, and should also try the folwling syntax:
DoCmd.OpenReport
"contract", acViewPreview, , "[customer_ID]=" & Me![customer_ID]
use the ! in place of dot..
as others pointed out, try:
msgbox "id is currently = " & me![customer_id]
"contract", acViewPreview, , "[customer_ID]=" & Me![customer_ID]
Does the customer is show with the above msgbox? you *must* get that
msgbox code t work.
(when it finally works..you can remove it for production version).
If the msgbox code works fine, then need to look at this part:
"contract", acViewPreview, , "[customer_ID]=" & Me![customer_ID]
"[customer_ID] = "
Customer_id is the name of the field in the REPORT..not our form that we
using to restrict the reports output....
So, double check if the report has this field.
Further, make sure the report is closed before you run the above code....
So, from this line of code (it would be all on one line of code):
DoCmd.OpenReport
"contract", acViewPreview, , "[customer_ID]=" & Me![customer_ID]
"[customer_id] = " is the field name in the target reprot, and
me![customer_id] is the name of the field in our current form....
It not clear which of the above is causing the "prompt" to occur -- you
should not be seeing a prompt..
Also DO CHECK can you run the report on its own -- no prompts should occur,
and all records should show.. You MUST check this!!
So, if the msgbox code works, then it is the target report that does NOT
have
[customer_id] in the field list....
So, put in the msgbox code....it should show you the current customer id.
The above code assumes customer_id is a autonumber field...correct??
So, check all of the above things...and, you code MUST compile before you
attempt to run it...