Results 1 to 3 of 3
  1. #1
    Phred is offline Competent Performer
    Windows XP Access 2010 (version 14.0)
    Join Date
    Dec 2009
    Posts
    246

    Data Type Mismatch in SQL


    Today 02:08 PM
    Phred

    I am getting a data type mismatch on my append query. I printed out the results of the query in the immediate window -- at bottom. The variables pick up correctly from a form and the query shows the correct info is being processed.

    I can't seem to find the mismatch. My variables are Integers, the table number fields are Long Integer.

    Dim intCatID As Integer, stCatName As String, intMealId As Integer, dtDateAssigned As Date, stMealName As String, stSQL As String,

    My table fields match as to data type, I think.

    stSQL = "INSERT INTO Tbl_ScheduledMeal" _
    & "( CategoryID, DayAssigned, CategoryName, MealID, MealName )" _
    & "VALUES (" & intCatID & ", #" & dtDateAssigned & "#,'" & stCatName & "'," & intMealId & ",'" & stMealName & "');"

    Results of Immediate window show the data is correct. I must have a problem with my table but I can't see where the problem is.



    See attached pic of table fields.

    INSERT INTO Tbl_ScheduledMeal( CategoryID, DayAssigned, CategoryName, MealID, MealName )
    VALUES (7, #1/27/2012#,'BOX LUNCH - PRESCHOOL',142,'Banana Muffin - Preschool');

  2. #2
    Stingaway is offline Efficiency Junkie
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2011
    Location
    The deep south. Keep going until you hit water basically.
    Posts
    224
    Might try removing one data element at a time to see which one is actually causing the data type mismatch.

    You could just edit the text you pasted from the immediate window and remove one at a time, that way you could at least tell where the error is...

  3. #3
    Phred is offline Competent Performer
    Windows XP Access 2010 (version 14.0)
    Join Date
    Dec 2009
    Posts
    246

    It worked

    Hey thanks that did it. I hadn't thought about running one variable at a time but it sure grabbed the problem. This immediate window stuff is really cool.

    Thanks

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Data type mismatch error
    By Tomfernandez1 in forum Programming
    Replies: 5
    Last Post: 10-05-2012, 07:27 AM
  2. Data type mismatch error
    By AccessUser123 in forum Queries
    Replies: 1
    Last Post: 05-22-2011, 07:48 PM
  3. Data Type Mismatch
    By timmy in forum Programming
    Replies: 9
    Last Post: 04-12-2011, 03:48 AM
  4. Data type mismatch in query
    By thart21 in forum Queries
    Replies: 8
    Last Post: 10-01-2010, 01:40 PM
  5. data type mismatch
    By jgelpi16 in forum Programming
    Replies: 5
    Last Post: 08-02-2010, 04:15 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums