DoCmd (1 Viewer)

mike60smart

Registered User.
Local time
Today, 11:47
Joined
Aug 6, 2017
Messages
1,899
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

You've got your good things, and you've got mine.
Local time
Today, 07:47
Joined
May 21, 2018
Messages
8,463
"[ContractID]=" & Me.ContractID " And [sellerID] = " & Me.txtSellerID

Assuming numeric
 

mike60smart

Registered User.
Local time
Today, 11:47
Joined
Aug 6, 2017
Messages
1,899
Hi MajP

I get the following error when I try that?

Error.PNG
 

Gasman

Enthusiastic Amateur
Local time
Today, 11:47
Joined
Sep 21, 2011
Messages
14,038
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.
Local time
Today, 11:47
Joined
Aug 6, 2017
Messages
1,899
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

You've got your good things, and you've got mine.
Local time
Today, 07:47
Joined
May 21, 2018
Messages
8,463
Forgot the ampersand
"[ContractID]=" & Me.ContractID & " And [sellerID] = " & Me.txtSellerID
 

Users who are viewing this thread

Top Bottom