Results 1 to 3 of 3
  1. #1
    jkd is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2014
    Posts
    2

    error 13 type mismatch

    I'm running a simple code to set several fields to "". The fields are sequentially numbered so I created a loop to run through them. I get a type mismatched at 8 on the first list and 10 on the second list. If it didn't work at all I would understand, but why it makes it so far then stops. I don't know. I set first list to stop at 7, and then discovered the second list would stop with the same error at 10. All of the fields are identically set up as Text 255 characters long. I can't see any difference between ERMB7 and ERMB8 or MB9 and MB10, no matter what I look at. Perhaps you guys can give me some direction where to look.

    Private Sub Command1171_Click()
    Dim badgefield As String
    Dim ctrl As Control
    Dim counter As Integer


    'Erase Previous Entries


    counter = 1
    Do While counter <= 16
    badgefield = "ERMB" & counter
    Set ctrl = Me.Controls(badgefield)


    ctrl = ""
    counter = counter + 1
    Loop


    counter = 1
    Do While counter <= 24
    badgefield = "MB" & counter
    Set ctrl = Me.Controls(badgefield)
    ctrl = ""
    counter = counter + 1
    Loop

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    Make sure field in table is set to allow empty string.

    Why are you setting fields to empty string? I never allow empty strings in tables. I prefer Null.

    Instead of counter, try For Next

    For i = 1 to 16
    Me.Controls("ERMB" & i) = ""
    Next

    For i = 1 to 24
    Me.Controls("MB" & i) = ""
    Next
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    jkd is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2014
    Posts
    2
    Thanks! That worked perfectly! I wonder why Do While didn't work, but For Next did?

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

Similar Threads

  1. Replies: 7
    Last Post: 07-24-2013, 02:01 PM
  2. type mismatch error 13
    By Compufreak in forum Access
    Replies: 3
    Last Post: 08-10-2012, 03:48 AM
  3. Replies: 1
    Last Post: 05-11-2012, 10:59 AM
  4. Error#13 Type Mismatch
    By Nistin27 in forum Access
    Replies: 8
    Last Post: 08-17-2011, 04:15 PM
  5. type mismatch error?
    By hlcarlin in forum Programming
    Replies: 1
    Last Post: 07-07-2011, 08:30 AM

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