Data Type Mismatch in Recordset

Hello,

I am getting a DataType Mismatch on this attempt to select a recordset from another recordsets ID field.  I have verified that both ID's in the tables are numbers.

Set rst = CurrentDb.OpenRecordset("SELECT * FROM [Here Are My Records] WHERE [ID] = '" & rstSend![ID] & "';")
vmccuneAsked:
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.

Pawan KumarDatabase ExpertCommented:
[Here Are My Records] --> you have table name correct ?
0
IrogSintaCommented:
Since the ID is a number you don't need the single quotes.  Those are for used for Text data types.
Set rst = CurrentDb.OpenRecordset("SELECT * FROM [Here Are My Records] WHERE [ID] = " & rstSend![ID]) 

Open in new window


Ron
0
Pawan KumarDatabase ExpertCommented:
Please try this -

You dont need a singleQuote if you are comparing numbers.

Set rst = CurrentDb.OpenRecordset("SELECT * FROM [Here Are My Records] WHERE [ID] = " & rstSend![ID] & "")
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

vmccuneAuthor Commented:
yes.
0
vmccuneAuthor Commented:
It is a query actually
0
Pawan KumarDatabase ExpertCommented:
Then use this

Set rst = CurrentDb.OpenRecordset("SELECT * FROM ([Here Are My Records]) as k WHERE [ID] = " & rstSend![ID] & "")
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
vmccuneAuthor Commented:
[Here are My Records]
Description      Our Information      Corrections      Id      Sort
First Name      Abhay            1986      1
0
Pawan KumarDatabase ExpertCommented:
Please try my last suggestion..
0
vmccuneAuthor Commented:
that thows up an error Syntax Error in From Clause
0
vmccuneAuthor Commented:
Got it.

Took out "As K"
0
vmccuneAuthor Commented:
Set rst = CurrentDb.OpenRecordset("SELECT * FROM ([Here Are My Records]) WHERE [ID] = " & rstSend![ID] & "")
0
IrogSintaCommented:
Have you tried my suggestion?  Btw @Pawan, you don't need to add the ampersand and quotes at the end since its a number and not text.

Ron
0
IrogSintaCommented:
Wow, I feel like a ghost here.  I gave the correct answer in the 2nd post in this thread and I was ignored completely.
0
Pawan KumarDatabase ExpertCommented:
@IrogSinta - You missed the brackets around [Here Are My Records].
0
IrogSintaCommented:
I have brackets around [Here Are My Records].  If you're referring to parenthesis, then those are not needed.  Neither is "as K" and the ending ampersand and quotes.

It would work fine just as:
Set rst = CurrentDb.OpenRecordset("SELECT * FROM [Here Are My Records] WHERE [ID] = " & rstSend![ID])
0
IrogSintaCommented:
@vmccune, in order to steer you correctly when writing similar SQL statements in Access, even though the answer you selected works, it has syntax that is unnecessary.   It doesn't matter if it's a table or query you're referencing, parenthesis ( ) around that object's name is not needed.  Now if your table name has spaces or certain reserved symbols (e.g. #, %) then you need brackets [ ] around the name.  You also don't need to end this particular statement with an ampersand and quotes since there's nothing inside the quotes.

Ron
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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.