Results 1 to 5 of 5
  1. #1
    boboivan is offline Advanced Beginner
    Windows 7 32bit Access 2013
    Join Date
    Dec 2015
    Posts
    65

    Type mismatch error 13

    Hi everyone!

    I get this error 13 type mismatch, when running the following code:



    Code:
    Private Sub Report_Load()
    Dim con As Integer
    Dim noc1 As Integer
    con = Forms("PaperWork").Worker
    noc1 = DLookup("IDman", "Managers", "[IDman]=1")
    If con = noc1 Then
    Me.Text17 = "AGREE," & vbCrLf & "John Brown"
    End If
    End Sub
    "Worker" field is a combo box with multiple values allowed. I think this causes the problem.
    Any help, please?
    Thx!

  2. #2
    ranman256's Avatar
    ranman256 is online now VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    13 is data mismatch.
    youre trying to put a string value into an integer variable.
    either CON or NOC1, my bet is NOC1 because DLookup("IDman", "Managers", "[IDman]=1") may not return an integers.
    if you get a NULL or a string, it will fail.

    dim NOC1 as variant, this way it will accept ANY reply.

  3. #3
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    and why are you bothering to lookup a value you already know in the first place?

    DLookup("IDman", "Managers", "[IDman]=1")

    It can only return 1, or null if it doesn't exist

  4. #4
    boboivan is offline Advanced Beginner
    Windows 7 32bit Access 2013
    Join Date
    Dec 2015
    Posts
    65
    Thx guys for your help!

    Ajax, you are totally right.
    Ranman, I've tried what you said, but for sure the problem is the type (multiple values allowed) of the field "Worker". I've changed the field intro one value only allowed and it works. But I need it to be with multiple values.

    So, the code after your advice would be:

    Code:
    Private Sub Report_Load()
    Dim con As Variant
    con = Forms("PaperWork").Worker
    If con = 1 Then
    Me.Text17 = "AGREE," & vbCrLf & "John Brown"
    End If
    End Sub
    but still doesn't work.

  5. #5
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2013 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    You don't need the "con" any more, you can put the IF in front of the Forms field. Put a stop point on the If statement and see what the value is of Worker. Check the first column of Worker, is it defined as a number?

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

Similar Threads

  1. Type 13 (Type Mismatch) error
    By sdel_nevo in forum Programming
    Replies: 5
    Last Post: 01-22-2016, 10:01 AM
  2. error 13 type mismatch
    By jkd in forum Programming
    Replies: 2
    Last Post: 04-19-2014, 09:46 PM
  3. Replies: 7
    Last Post: 07-24-2013, 02:01 PM
  4. type mismatch error 13
    By Compufreak in forum Access
    Replies: 3
    Last Post: 08-10-2012, 03:48 AM
  5. Replies: 1
    Last Post: 05-11-2012, 10:59 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