Go Back   Access World Forums > Microsoft Access Discussion > General

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 11-14-2019, 03:57 AM   #1
mike60smart
Newly Registered User
 
mike60smart's Avatar
 
Join Date: Aug 2017
Location: Dunbar, Scotland
Posts: 466
Thanks: 21
Thanked 93 Times in 92 Posts
mike60smart will become famous soon enough
DoCmd

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

mike60smart is offline   Reply With Quote
Old 11-14-2019, 04:08 AM   #2
MajP
Newly Registered User
 
Join Date: May 2018
Location: USA baby
Posts: 1,891
Thanks: 38
Thanked 572 Times in 539 Posts
MajP has a spectacular aura about MajP has a spectacular aura about
Re: DoCmd

"[ContractID]=" & Me.ContractID " And [sellerID] = " & Me.txtSellerID

Assuming numeric
MajP is online now   Reply With Quote
Old 11-14-2019, 04:15 AM   #3
mike60smart
Newly Registered User
 
mike60smart's Avatar
 
Join Date: Aug 2017
Location: Dunbar, Scotland
Posts: 466
Thanks: 21
Thanked 93 Times in 92 Posts
mike60smart will become famous soon enough
Re: DoCmd

Hi MajP

I get the following error when I try that?

Error.PNG

mike60smart is offline   Reply With Quote
Old 11-14-2019, 04:30 AM   #4
Gasman
Enthusiastic Amateur
 
Gasman's Avatar
 
Join Date: Sep 2011
Location: Swansea, South Wales,UK
Posts: 4,531
Thanks: 441
Thanked 841 Times in 812 Posts
Gasman is a jewel in the rough Gasman is a jewel in the rough Gasman is a jewel in the rough
Re: DoCmd

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
__________________
Access novice. Sometimes trying to give something back.
Access 2007

Please, please use code tag # when posting code snippets

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Gasman is offline   Reply With Quote
Old 11-14-2019, 04:32 AM   #5
mike60smart
Newly Registered User
 
mike60smart's Avatar
 
Join Date: Aug 2017
Location: Dunbar, Scotland
Posts: 466
Thanks: 21
Thanked 93 Times in 92 Posts
mike60smart will become famous soon enough
Re: DoCmd

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
mike60smart is offline   Reply With Quote
Old 11-14-2019, 04:46 AM   #6
MajP
Newly Registered User
 
Join Date: May 2018
Location: USA baby
Posts: 1,891
Thanks: 38
Thanked 572 Times in 539 Posts
MajP has a spectacular aura about MajP has a spectacular aura about
Re: DoCmd

Forgot the ampersand
"[ContractID]=" & Me.ContractID & " And [sellerID] = " & Me.txtSellerID

MajP is online now   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
DoCmd.OpenQuery vs DoCmd.RunSQL vs OpenRecordset Lee Mac Modules & VBA 2 11-29-2016 05:29 AM
Go From Docmd.openreport With Wherecondition To Docmd.transferspreadsheet, Access 201 MKaprielian Queries 5 07-02-2013 05:43 AM
Runtime error 2046 on doCmd.gotoRecord after doCmd.openReport Alexie Forms 3 06-03-2010 02:58 AM
Using Docmd. OutputTo and Docmd.transfertxt odrap Modules & VBA 0 02-05-2009 12:24 PM
docmd.outputto vs docmd.transferspreadsheet like Reports 0 11-08-2006 10:28 PM




All times are GMT -8. The time now is 01:21 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World