Results 1 to 4 of 4
  1. #1
    joelmeaders is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jan 2012
    Posts
    33

    Insert Into = Type Mismatch

    I built a function that automatically searches through unbound text boxes based on certain tags they have. The text boxes are named with the field name they belong to. It takes the names and the values, creates an sql string and adds a new record.



    In this case the function builds an INSERT string to add a record and the string is as follows (example):

    Code:
    INSERT INTO [tbl_Invoices] ([InvoiceEntered], [InvoiceType], [InvoiceNo], [InvoiceDate], [InvAmount], [Unit], [ReceivedAgency], [UserName], [PaymentType], [ContractNo], [AgencyRefNo]) VALUES ('2/7/2012 9:22:58 AM', 'Misc', '123', '3/2/2012', '56', 'MOOET', '2/7/2012', 'meadejx', 'General A/P', '606M15', '606M15');
    It is assigned to mySQL and it is ran using:
    CurrentDb.Execute mySQL, dbFailOnError

    This runs perfectly the first time. The form and all values are then reset with a reset function and can be used again to enter or work another invoice.

    I have never had problems with this function before and it always has worked until I just upgraded everything to Access 2007 formats. Now on the second consecutive entry I get:
    ERROR - Type Mismatch
    on the CurrentDb.Execute line.

    I can close the form, open it again, enter all of the same values that failed previously and it saves perfectly. Once I enter another it fails.

    I never had issues with 2003...

  2. #2
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Dates generally are delimited by #, not quote: #01/01/2012#

  3. #3
    joelmeaders is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jan 2012
    Posts
    33
    Quote Originally Posted by aytee111 View Post
    Dates generally are delimited by #, not quote: #01/01/2012#
    Yeah but what gets me is that this has always worked, and works the first time around on the form. I figured it only worked with quotes because it was a multiple field insert query. In fact, it has always worked with all data types regardless some how.

  4. #4
    joelmeaders is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jan 2012
    Posts
    33
    So it turns out that Access randomly got to pick and choose the errors to display here.

    Putting the dates inside of #'s gave the same errors. After following the whole process through there was a prerequisite record (temporary misc contract) not being saved in another table on the second go around because the function which saved the contract was picking up a vbNullString in a box it shouldn't have been accessing causing the prereq save to fail (and not throwing an error). That should have caused an error for this save that said matching record required in tbl______.

    Once that was fixed it throws no type mismatch error even though the dates are again enclosed within quotes instead of #'s. It only threw that error instead of the missing record error.

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

Similar Threads

  1. Type mismatch from InputBox
    By sephiroth2906 in forum Programming
    Replies: 2
    Last Post: 09-15-2011, 06:59 AM
  2. Type Mismatch....WHY?!!?
    By jgelpi16 in forum Queries
    Replies: 9
    Last Post: 03-07-2011, 09:18 AM
  3. Type Mismatch
    By Alex Motilal in forum Programming
    Replies: 10
    Last Post: 02-13-2011, 05:42 AM
  4. Type mismatch
    By jgelpi16 in forum Programming
    Replies: 1
    Last Post: 08-07-2010, 06:54 AM
  5. Type Mismatch - HELP!
    By jgelpi in forum Programming
    Replies: 3
    Last Post: 07-17-2009, 03:53 PM

Tags for this Thread

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