473,320 Members | 1,872 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,320 software developers and data experts.

Datatype Mismatch

147 100+
Does anyone know where my error is on this? I keep getting a data type mismatch error.

My fields and their type are:

EmployeeID - Text
OTDate - Date
HoursPay - Double
RateofPay - Currency
TypeOfJob - integer
Notes - text
ID - Autonumber

My Code is as follows:

<Code>
Dim intTypeOfJob As Integer
Dim strSQL As String
Dim dblHoursPay As Double
If [TypeOfJob] = 1 And [HoursPay] > 8 Then
intTypeOfJob = 99
dblHoursPay = [HoursPay] - 8
strSQL = "INSERT INTO tblOvertime VALUES (""" & EmployeeID _
& """, #" & OTDate & "#, " & dblHoursPay & ", " & RateOfPay & ", " _
& intTypeOfJob & ", """ & Notes & """," & ID & ")"
CurrentDb.Execute strSQL, dbFailOnError
End If
<End Code>

Thanks
Jan 15 '09 #1
5 1602
RuralGuy
375 Expert 256MB
You have not specified the fields into which to insert the Values().
Jan 15 '09 #2
DAHMB
147 100+
How would I do that my fields are:
EmployeeID - Text
OTDate - Date
HoursPay - Double
RateofPay - Currency
TypeOfJob - integer
Notes - text
ID - Autonumber

I am very new at this and am learning from this site

Thanks
Dan
Jan 15 '09 #3
RuralGuy
375 Expert 256MB
Try something like:
Expand|Select|Wrap|Line Numbers
  1. Dim intTypeOfJob As Integer
  2. Dim strSQL As String
  3. Dim dblHoursPay As Double
  4. If [TypeOfJob] = 1 And [HoursPay] > 8 Then
  5.    intTypeOfJob = 99
  6.    dblHoursPay = [HoursPay] - 8
  7.    strSQL = "INSERT INTO tblOvertime (EmployeeID, OTDate, HoursPay, " & _
  8.             "RateofPay, TypeOfJob, Notes, ID) " & _
  9.             "VALUES (""" & EmployeeID & """, #" & OTDate & "#, " & dblHoursPay & _
  10.             ", " & RateOfPay & ", " & intTypeOfJob & ", """ & Notes & """," & ID & ")"
  11.    CurrentDb.Execute strSQL, dbFailOnError
  12. End If
Jan 15 '09 #4
DAHMB
147 100+
Yes that is almnost it!!!!!!!!!!!!!!! except I had to remove the ID field because it was autonumber. Now it works!!!!!!!!!!!!

Thankyou
Jan 15 '09 #5
RuralGuy
375 Expert 256MB
You're welcome. Thanks for posting back with your success.
Jan 15 '09 #6

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

Similar topics

2
by: Stephen Briley | last post by:
For some reason, my posts are scrubbed as attachments. Lets hope that sending from the yahoo account works. I'm new to Python and I'm trying to do some database work with MS Access, but I can't...
2
by: Steve Briley | last post by:
I'm new to Python and I'm trying to do some database work with MS Access, but I can't seem to get around a "datatype mismatch error".&nbsp; Here's an example table that I'm working with... ...
4
by: c_bowen | last post by:
I am using Visual Studio .NET 2003 with SQL Server 2000. I am trying to insert the date and time into a SQL database by using hour(now). I am having a hard time trying to figure out which datatype...
1
by: Sam Gledhill | last post by:
I hope somebody can help me, I have a problem executing this line of sql: Dim rstur As New Recordset Dim sql As String sql = "SELECT * FROM tblpat WHERE ='" & Me! & "'" Set rstur =...
1
by: Ken | last post by:
I wrote a function to use in queries that takes a date and adds or subtracts a certain length time and then returns the new value. There are times when my function needs to return Null values. ...
6
by: rn5a | last post by:
I am inserting records in a MS-Access database table. The data type of one of the columns named *OrderDate* in the DB table is Date/Time. This is the SQL query I am using to insert the records in...
2
by: chirag1989 | last post by:
I m havin an error of datatype mismatch actual here i m askin user to input the code in text box and then searchin the record havin that code in database the problem is the code field Bnum is of...
0
by: Snoopy33 | last post by:
I have a query that builds a date from a text field with the date imput as yyyymmdd in the query, so i have to piece it together in my expression as follows: exp:...
9
by: rscheinberg | last post by:
I am working in Access 2007 attempting to grab 2 characters from a text field named ProjectNumber. After determining what 2 digits to add in front to make it a year, I need to do that. I have done...
14
by: rscheinberg | last post by:
I am working in Access 2007 attempting to grab 2 characters from a text field named ProjectNumber. After determining what 2 digits to add in front to make it a year, I need to do that. I have done...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

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.