OPEN ARGS Trouble

D

DS

I'm opening the same report from different forms so I want to use the
OpenArgs.

This is the recordsource of my report. Its set on Open

Me.RecordSource = "SELECT tblCheckDetails.CDCheckID,
tblCheckDetails.CDQuantity, " & _
"IIf([CDSub]=1,tblItems.ItemName,IIf([CDSub]=2 Or [CDSub]=3,"" "" &
tblItems.ItemName,IIf([CDSub]=4,"" "" &
tblItems.ItemName,IIf([CDSub]=5,"" "" &
tblItems.ItemName,IIf([CDSub]=6,tblItems.ItemName))))) AS NAME, " & _
"IPRICE([CDQuantity],[CDPrice],[CDDiscountAmount],[CDDiscountPercent],[CDDiscountDP],[CDDiscountWhere],[CDTaxRate],[CDInclusive])
AS PRICE, " & _
"tblChecks.ChkDate, tblChecks.ChkTime, [ChkAlias] & "" / "" & [ChkGuests] AS
INFO,tblChecks.ChkServer " & _
"FROM (tblChecks INNER JOIN tblCheckDetails ON tblChecks.CheckID =
tblCheckDetails.CDCheckID) " & _
"INNER JOIN tblItems ON tblCheckDetails.CDItemID = tblItems.ItemID " & _
"WHERE (((tblCheckDetails.CDCheckID)=[OpenArgs]))" & _
"UNION " & _
"SELECT tblDiscountDetails.CDCheckID, tblDiscountDetails.CDQuantity, " & _
"tblDiscounts.DiscountName AS NAME,
DPRICE([CDDiscountDP],[CDDiscountAmount],[CDDiscountPercent]) AS PRICE, " &
_
"tblChecks.ChkDate, tblChecks.ChkTime, """" AS INFO,tblChecks.ChkServer " &
_
"FROM (tblChecks INNER JOIN tblDiscountDetails ON tblChecks.CheckID =
tblDiscountDetails.CDCheckID) " & _
"INNER JOIN tblDiscounts ON tblDiscountDetails.CDDiscountID =
tblDiscounts.DiscountID " & _
"WHERE (((tblDiscountDetails.CDCheckID)=[OpenArgs]));"

The Command Button has this behind it
DoCmd.OpenReport,"rptCheck",,,,,,Me.TextID

However I keep getting a prompted for the OpenArgs when the report opens.
Any Direction appreciated.
Thanks
DS
 
D

Duane Hookom

Without looking to deep into this, your code should be:
"WHERE tblDiscountDetails.CDCheckID=" & [OpenArgs]
This assumes CDCheckID is numeric. If it is text, try:
"WHERE tblDiscountDetails.CDCheckID=""" & [OpenArgs] & """"
 
D

DS

Thanks Duane it works! I did this...
"WHERE tblCheckDetails.CDCheckID=" & [OpenArgs] & " " & _
"UNION " & _
This also works...
" & CSTR(OpenArgs) & "
for whatever reason...it's a numeric field.
Once again, Thank You.
DS
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

SQL ORDER BY 1
SQL Rowsource 1

Top