473,396 Members | 1,942 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Type Mismatch Error

84
The SQL below is returning a type mismatch error and I cannot figure out why.
The ID field in RANDOM_RECORD is a number field. Any one have any idea as to why i am getting the error?

Dim stRecordTotal As String
Dim stRecordResult as String
Dim stRecord As String

stRecordTotal = 0
stRecordResult = 0

stRecordTotal = "SELECT Count(RANDOM_RECORDS.ID) " & _
"FROM RANDOM_RECORDS "

stRecordResult = (stRecordTotal / 4)

stRecord = "INSERT INTO RESULTS ( stRecordResult) "

DoCmd.RunSQL stRecord
Sep 10 '07 #1
5 1114
mlcampeau
296 Expert 100+
The SQL below is returning a type mismatch error and I cannot figure out why.
The ID field in RANDOM_RECORD is a number field. Any one have any idea as to why i am getting the error?

Dim stRecordTotal As String
Dim stRecordResult as String
Dim stRecord As String

stRecordTotal = 0
stRecordResult = 0

stRecordTotal = "SELECT Count(RANDOM_RECORDS.ID) " & _
"FROM RANDOM_RECORDS "

stRecordResult = (stRecordTotal / 4)

stRecord = "INSERT INTO RESULTS ( stRecordResult) "

DoCmd.RunSQL stRecord
I really don't know VBA, but maybe it has to do with the fact that you're trying to perform math on variables that you declared as strings?? Try changing it to Dim stRecordTotal As Number (not sure if 'Number' is correct...as I said I really don't know VBA, but I hope you get the picture of what I'm trying to say). If that doesn't work, let us know what the error message is and do a debug and let us know which line of code it is having problems with.
Sep 10 '07 #2
FishVal
2,653 Expert 2GB
The SQL below is returning a type mismatch error and I cannot figure out why.
The ID field in RANDOM_RECORD is a number field. Any one have any idea as to why i am getting the error?

Dim stRecordTotal As String
Dim stRecordResult as String
Dim stRecord As String

stRecordTotal = 0
stRecordResult = 0

stRecordTotal = "SELECT Count(RANDOM_RECORDS.ID) " & _
"FROM RANDOM_RECORDS "

stRecordResult = (stRecordTotal / 4)

stRecord = "INSERT INTO RESULTS ( stRecordResult) "

DoCmd.RunSQL stRecord
Hi, sesling.

You simply confuse Access. He doesn't know how to divide "SELECT Count(RANDOM_RECORDS.ID) FROM RANDOM_RECORDS " into 4 parts. ;)

If you want to retrieve records count without dealing with recordsets you should take a look at DCount function.

And check the second query syntax and logic. If you have difficulties with SQL syntax, then build a query with functionality you need in Query builder, change view to "SQL View" and copy SQL expression to your code.

Good luck.
Sep 10 '07 #3
sesling
84
Hi, sesling.

You simply confuse Access. He doesn't know how to divide "SELECT Count(RANDOM_RECORDS.ID) FROM RANDOM_RECORDS " into 4 parts. ;)

If you want to retrieve records count without dealing with recordsets you should take a look at DCount function.

And check the second query syntax and logic. If you have difficulties with SQL syntax, then build a query with functionality you need in Query builder, change view to "SQL View" and copy SQL expression to your code.

Good luck.
The DCOUNT worked. I am now trying to insert the results into an existing table but I am getting a syntax error. Below is the statement I am trying to run


stInfoPercent = (stInfoTotal / stRecordTotal)
stNonPercent = (stNonTotal / stRecordTotal)
stNPPercent = (stNPTotal / stRecordTotal)

stInsertResults = "INSERT INTO PERCENTAGES (stInfoPercent, stNonPercent, stNPPercent)"

DoCmd.RunSQL stInsertResults
Sep 10 '07 #4
FishVal
2,653 Expert 2GB
The DCOUNT worked. I am now trying to insert the results into an existing table but I am getting a syntax error. Below is the statement I am trying to run


stInfoPercent = (stInfoTotal / stRecordTotal)
stNonPercent = (stNonTotal / stRecordTotal)
stNPPercent = (stNPTotal / stRecordTotal)

stInsertResults = "INSERT INTO PERCENTAGES (stInfoPercent, stNonPercent, stNPPercent)"

DoCmd.RunSQL stInsertResults
You have an invalid "INSERT" syntax. Look Access help "INSERT INTO Statement" topic.
Sep 10 '07 #5
sesling
84
You have an invalid "INSERT" syntax. Look Access help "INSERT INTO Statement" topic.
Found the issue. thanks for the pointer
Sep 10 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Arun Wadhawan | last post by:
Hello MY SQL Server is causing me this problem : Microsoft VBScript runtime error '800a000d' Type mismatch: 'ident' >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> I am getting from...
1
by: LJgrnl | last post by:
I've got a type mismatch error that's driving me nutty. Variable blnNoData has the initial value False. If a recordset comes back empty (both .EOF and ..BOF are true) then blnNoData is set to...
4
by: Mike | last post by:
I am getting a type mismatch error when I do a bulk insert. ---Begin Error Msg--- Server: Msg 4864, Level 16, State 1, Line 1 Bulk insert data conversion error (type mismatch) for row 1, column...
0
by: news.paradise.net.nz | last post by:
I have been developing access databases for over 5 years. I have a large database and I have struck this problem with it before but can find nothing in help or online. Access 2000 I have a query...
3
by: amitbadgi | last post by:
I am getting teh following error while converting an asp application to asp.net, Exception Details: System.Runtime.InteropServices.COMException: Type mismatch. Source Error: Line...
1
by: Brett | last post by:
I have a form that calls a method within a DLL. By clicking a button on the form, the DLL is instantiated and the SaveOutlookMessage() method invoked. The DLL code copies messages from Outlook to...
6
by: Howard Kaikow | last post by:
I'm doing a VB 6 project in which I am trying to protect against type mismatch errors. Is the process any different in VB .NET? Here's what I'm doing in VB 6. I have an ActiveX DLL. The...
1
by: jodyblau | last post by:
I have a database which works fine until I create and MDE file. Once I create the MDE, when I open a particular form I get a "Type Mismatch" error. Because its an MDE file, I can't step through...
19
by: zz12 | last post by:
Hello, is there a setting in IIS 5.0 that would quickly fix the following error?: Microsoft VBScript runtime (0x800A000D) Type mismatch It's strange because some of our .asp pages were...
1
by: nckinfutz | last post by:
hello, I am having a problem with an access database. this is not my database and I did not create it, nor am I very good at access. however, I am a network engineer and that is why this problem...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.