DoCmd (1 Viewer)

mike60smart

Registered User
Joined
Aug 6, 2017
Messages
497
Hi Everyone

Can anyone tell me where I am going wrong with the Syntax in the following DoCmd?

Code:
DoCmd.OpenReport "rptCurrentSale", acPreview, , "[ContractID]=" & Me.ContractID And "[sellerID] = " & Me.txtSellerID
Any help appreciated
 

MajP

I wish I could go back in time... I'd take state
Joined
May 21, 2018
Messages
2,429
"[ContractID]=" & Me.ContractID " And [sellerID] = " & Me.txtSellerID

Assuming numeric
 

mike60smart

Registered User
Joined
Aug 6, 2017
Messages
497
Hi MajP

I get the following error when I try that?

Error.PNG
 

Gasman

Enthusiastic Amateur
Joined
Sep 21, 2011
Messages
5,017
Code:
DoCmd.OpenReport "rptCurrentSale", acPreview, , "[ContractID]=" & Me.ContractID  & " And  [sellerID] = " & Me.txtSellerID
FWIW I tend to put filter/where criteria into a string and then use that.?

That way I can debug.print it.

HTH
 

mike60smart

Registered User
Joined
Aug 6, 2017
Messages
497
Hi MajP

Thanks for looking but I have found a solution using this:-

Code:
DoCmd.OpenReport "rptCurrentSale", acPreview, , "[ContractID]= Forms![Create Contract]![ContractID] And [sellerID] = Forms![Create Contract]![txtSellerID]"
Thanks again
:)
 

MajP

I wish I could go back in time... I'd take state
Joined
May 21, 2018
Messages
2,429
Forgot the ampersand
"[ContractID]=" & Me.ContractID & " And [sellerID] = " & Me.txtSellerID
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top Bottom