UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Issues With Docmd.openreport, Access 2010    
 
   
Buwaxo
post Sep 12 2017, 10:06 AM
Post#1



Posts: 16
Joined: 12-September 17



Hello guys I´m new with access and I´m making a print buttom, I´m able to print a single report with a ID number, but i don´t know if I can use more than one condition on the WHERE section of the docmd.openreport command. I uploaded photos of the code and the form I´m using hope you guys can help figured this out thanks. If more information is needed I´ll be checking this out
Attached File(s)
Attached File  formulario.jpg ( 143.16K )Number of downloads: 2
Attached File  imprimir.jpg ( 234.76K )Number of downloads: 3
 
Go to the top of the page
 
theDBguy
post Sep 12 2017, 10:09 AM
Post#2


Access Wiki and Forums Moderator
Posts: 71,012
Joined: 19-June 07
From: SunnySandyEggo


Hi,

Welcome to UtterAccess!
welcome2UA.gif

Yes, you should be able to use more than one criteria in the WhereCondition argument of the OpenReport method. The syntax might look something like:

"FieldName=" & Me.ControlName & " AND OtherFieldName=" & Me.OtherControlName

Hope it helps...

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Microsoft Access MVP | Access Website | Access Blog | Email
Go to the top of the page
 
Buwaxo
post Sep 12 2017, 10:57 AM
Post#3



Posts: 16
Joined: 12-September 17



I did what you tell me it worked better, but now I´m having the error 3464 Data type mismatch in criteria expression and the information show it´s correct any ideas?
Go to the top of the page
 
Minty
post Sep 12 2017, 11:07 AM
Post#4



Posts: 68
Joined: 5-July 16



If your criteria involves text you will need to escape them with quotes, so something like

"YourTextField = '" & Me.yourTextControl & "' AND YourNumberFIeld = " Me.YourNumberControl
Go to the top of the page
 
theDBguy
post Sep 12 2017, 11:12 AM
Post#5


Access Wiki and Forums Moderator
Posts: 71,012
Joined: 19-June 07
From: SunnySandyEggo


Hi,

Minty is correct! (Welcome to UtterAccess, Minty.)

I said the criteria "might" look like my example because I had no idea what data types you have.

So, if you have numeric data types, you can use my example. If you have a text data type, you can use Minty's example. If you have a date data type, you'll need a third example.

What is your data type?

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Microsoft Access MVP | Access Website | Access Blog | Email
Go to the top of the page
 
Minty
post Sep 12 2017, 11:20 AM
Post#6



Posts: 68
Joined: 5-July 16



@theDBguy - Thank you - long time lurker - more active on another forum... wink.gif
Go to the top of the page
 
theDBguy
post Sep 12 2017, 11:42 AM
Post#7


Access Wiki and Forums Moderator
Posts: 71,012
Joined: 19-June 07
From: SunnySandyEggo


Re: "more active on another forum..."

We won't hold it against you. smile.gif

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Microsoft Access MVP | Access Website | Access Blog | Email
Go to the top of the page
 
Buwaxo
post Sep 12 2017, 11:56 AM
Post#8



Posts: 16
Joined: 12-September 17



Im using a text criteria so I´ll have to use '" & me.text & "' right?
Go to the top of the page
 
Buwaxo
post Sep 12 2017, 12:02 PM
Post#9



Posts: 16
Joined: 12-September 17



It´s working this is great thank you guys notworthy.gif
Go to the top of the page
 
theDBguy
post Sep 12 2017, 12:10 PM
Post#10


Access Wiki and Forums Moderator
Posts: 71,012
Joined: 19-June 07
From: SunnySandyEggo


Hi,

Congratulations! Glad to hear you got it to work. Good luck with your project.

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Microsoft Access MVP | Access Website | Access Blog | Email
Go to the top of the page
 
Buwaxo
post Sep 12 2017, 12:15 PM
Post#11



Posts: 16
Joined: 12-September 17



Last question what´s the criteria for the date, I think that I would need it.Thank you
Go to the top of the page
 
theDBguy
post Sep 12 2017, 12:19 PM
Post#12


Access Wiki and Forums Moderator
Posts: 71,012
Joined: 19-June 07
From: SunnySandyEggo


I prefer something like:

CODE
"DateField=#" & Format(Me.DateControl, "yyyy-mm-dd") & "#"

Hope it helps...

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Microsoft Access MVP | Access Website | Access Blog | Email
Go to the top of the page
 
Buwaxo
post Sep 12 2017, 02:23 PM
Post#13



Posts: 16
Joined: 12-September 17



It worked great thank you thumbup.gif
Go to the top of the page
 
theDBguy
post Sep 12 2017, 04:47 PM
Post#14


Access Wiki and Forums Moderator
Posts: 71,012
Joined: 19-June 07
From: SunnySandyEggo


You're welcome!

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Microsoft Access MVP | Access Website | Access Blog | Email
Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    18th November 2017 - 07:24 AM