Results 1 to 6 of 6
  1. #1
    sdel_nevo is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2013
    Location
    Gloucester, UK
    Posts
    402

    Type 13 (Type Mismatch) error

    Hi Everone



    I have an issue with athe dcount below, when the code runs im getting a Type 13 (Type Mismatch) when i try to run this dcount


    Dim countID As String
    countID = DCount("SOIID", "SOIDetails", "WORKORDERID='" & Forms!SOIAdddetails!WorkOrderTXTBox & "'" And LPosition > 0)

    this is the code on the form this all runs when a text feilds after update event.

    Dim LPosition As String
    LPosition = InStr(Me.PartNumberDescriptionTXTBox, "*")

    If LPosition > 0 Then
    Me.Ends7 = True
    End If

    If LPosition = 0 Then
    Me.Ends7 = False
    End If

    Dim countID As String
    countID = DCount("SOIID", "SOIDetails", "WORKORDERID='" & Forms!SOIAdddetails!WorkOrderTXTBox & "'" And LPosition > 0)


    if i comment out this line countID = DCount("SOIID", "SOIDetails", "WORKORDERID='" & Forms!SOIAdddetails!WorkOrderTXTBox & "'" And Private Sub WorkOrderTXTBox_AfterUpdate() > 0) no error is produced


    how do i include the variable LPosition as a critria in my dcount?

    many thanks
    steve

  2. #2
    cyanidem's Avatar
    cyanidem is offline Competent Performer
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2015
    Location
    Consett, UK
    Posts
    270
    DCount returns number, and you declared countID as string and then you're trying to set string to number:
    countID = DCount(.....)


    Edit:
    Actually same problem with LPosition. Declared as string and then:
    LPosition = InStr(....)
    but InStr returns integer, not string.

  3. #3
    sdel_nevo is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2013
    Location
    Gloucester, UK
    Posts
    402
    Hi cyanidem

    many thyanks for getting back

    i have changed countid to single
    and
    Lposition as integer but im getting the same error

    i have also tried double

    kind regards

  4. #4
    cyanidem's Avatar
    cyanidem is offline Competent Performer
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2015
    Location
    Consett, UK
    Posts
    270
    Could you upload your database?

  5. #5
    sdel_nevo is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2013
    Location
    Gloucester, UK
    Posts
    402
    Hi Cyanidem

    the most odd thing is happening to this database, when i made the changes above i still got the error messages, when i created a new blank form and copied my code into it everything worked?

    i have had this issue recently so what i think i need to do is to cteate a new blank database and try importing all the tables, forms, reports and querys into it.

    many thanks for your help its all sorted.

    Kind regards

    Steve

  6. #6
    Missinglinq's Avatar
    Missinglinq is online now VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    2,942
    Quote Originally Posted by sdel_nevo View Post

    ...when i made the changes above i still got the error messages, when i created a new blank form and copied my code into it everything worked...
    Doing this is the first line of defense when corruption of the database itself is suspected, which would tend to suggest that your db was, in fact, corrupted!

    Allen Browne has an excellent article on the prevention of corruption, during development and after distribution, that you probably need to look at:

    http://allenbrowne.com/ser-25.html

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

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

Similar Threads

  1. Type Mismatch Error
    By thexxvi in forum Access
    Replies: 3
    Last Post: 11-10-2015, 10:11 AM
  2. Error 13 Type Mismatch
    By jj1 in forum Access
    Replies: 5
    Last Post: 05-21-2014, 12:33 PM
  3. error 13 type mismatch
    By jkd in forum Programming
    Replies: 2
    Last Post: 04-19-2014, 09:46 PM
  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

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 - Senior Forums