trivial but frustrating: datatype mismatch

Hi experts -
I'm trying to invoke a form with this line:
DoCmd.OpenForm "Vendor_Invoice_Browse", , , "[Vendor_ID]=" & Me.txtVendor_ID & " and [invoiceno]=" & Me.txtInvoiceNo & " and [invoicedate]=#" & Me.txtInvoiceDate & "#", , 3

but it is having problems with the [invoiceno]=me.txtinvoiceno. (I tested - the line works fine when I remove this)

Invoiceno is a TEXT field in the source table, and me.txtinvoiceno is pulling from a query that pulls directly from the table.

any ideas?

Thanks!
terpsichoreAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

IrogSintaCommented:
Since it is Text, you need single quotes around it.
DoCmd.OpenForm "Vendor_Invoice_Browse", , , "[Vendor_ID]=" & Me.txtVendor_ID & " and [invoiceno]='" & Me.txtInvoiceNo & "' and [invoicedate]=#" & Me.txtInvoiceDate & "#", , 3

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mbizupCommented:
Try this:

DoCmd.OpenForm "Vendor_Invoice_Browse", , , "[Vendor_ID]=" & Me.txtVendor_ID & " and [invoiceno]='" & Me.txtInvoiceNo & "' and [invoicedate]=#" & Me.txtInvoiceDate & "#", , 3

Open in new window

0
Jim Dettman (Microsoft MVP/ EE MVE)President / OwnerCommented:
Data type mis-match simply means your using a string when it should be a numeric, or the reverese.

As Dale said, you need quotes around it so it's treated like a string.  I like however to use chr$(34) (which is the quote character in ASCII):

DoCmd.OpenForm "Vendor_Invoice_Browse", , , "[Vendor_ID]=" & Me.txtVendor_ID & " and [invoiceno]=" & chr$(34) & Me.txtInvoiceNo & chr$(34) & " and [invoicedate]=#" & Me.txtInvoiceDate & "#", , 3

 which makes it easy to see the things you are specifically trying to surround with quotes.

with "' together, it's often hard to tell what's first   "  or '

Jim.
0
Newly released Acronis True Image 2019

In announcing the release of the 15th Anniversary Edition of Acronis True Image 2019, the company revealed that its artificial intelligence-based anti-ransomware technology – stopped more than 200,000 ransomware attacks on 150,000 customers last year.

IrogSintaCommented:
@Jim,
Mbizup prefers to be called Miriam instead of Dale.
:-)

Ron
0
terpsichoreAuthor Commented:
wow - brilliant comments - the first two within a few seconds of each other, so I need to split credit. JDettman's comment provided interesting detail.
0
Jim Dettman (Microsoft MVP/ EE MVE)President / OwnerCommented:
No, I called you Dale<g>  Had a 50/50 shot I guess; one of you always seem to be in every question<g>

Still working on the second cup of coffee this morning, so there's hope yet for today...

Jim.
0
IrogSintaCommented:
Lol, I know you were referring to me. I think everyone knows Miriam :-)  I really should sign my posts like you do, but I tend to forget.

Ron
0
mbizupCommented:
:-)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.