Results 1 to 4 of 4
  1. #1
    thexxvi is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    May 2015
    Posts
    63

    Type Mismatch Error

    Good morning.

    I am working on a form and have a textbox (called Transaction ID) that allows a user to type in a string of 18 characters, no more, no less. The Transaction ID textbox is bound to the table called "Credit Listening Data" and the corresponding field in the table is called Transaction ID. I have an 'After Update' code in vba that reads like this:

    Private Sub Transaction_ID_AfterUpdate()
    If (DLookup("[Transaction ID]", "Credit Listening Data", "[Transaction ID]=[Forms]![Credit Listening Form]![Transaction ID]")) Then
    MsgBox "The Transaction ID has already been used. Please enter a different Transaction ID.", vbInformation, "Duplicate Transaction ID"
    End If
    End Sub


    Whenever I enter a string into that field that's not a duplicate value in the table, everything works fine. When I type in a duplicate value, I get a 'Type Mismatch' error that points back to this portion of the VBA code.

    If (DLookup("[Transaction ID]", "Credit Listening Data", "[Transaction ID]=[Forms]![Credit Listening Form]![Transaction ID]")) Then


    Any thoughts on how to resolve this?

    Thank you in advance.

  2. #2
    NoellaG's Avatar
    NoellaG is offline VIP
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Jun 2010
    Location
    Belgium
    Posts
    1,046
    Hi,

    You have to pull the variable part of the criterium out of the quotes. As the id field is a string you could try:

    DLookup("[Transaction ID]", "Credit Listening Data", "[Transaction ID]= """ & [Forms]![Credit Listening Form]![Transaction ID] & """")

  3. #3
    thexxvi is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    May 2015
    Posts
    63
    Thanks for the thought. I tried it, but I'm still getting the same 'Type Mismatch' error on the same line.

  4. #4
    thexxvi is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    May 2015
    Posts
    63
    Alright so it looks like it's not really the code because it works fine when the field is all digits, but it doesn't work at all when there's any letters in the field. The table shows the field is short text and the field on the form is just a textbox. why would it react this way to letters? I need to be able to enter a combination of letters and numbers in the field, not just numbers.

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

Similar Threads

  1. Type Mismatch error... Please help...
    By craig1988 in forum Modules
    Replies: 5
    Last Post: 10-08-2015, 09:25 AM
  2. Replies: 7
    Last Post: 07-24-2013, 02:01 PM
  3. type mismatch error 13
    By Compufreak in forum Access
    Replies: 3
    Last Post: 08-10-2012, 03:48 AM
  4. Replies: 1
    Last Post: 05-11-2012, 10:59 AM
  5. type mismatch error?
    By hlcarlin in forum Programming
    Replies: 1
    Last Post: 07-07-2011, 08:30 AM

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