Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Help With this Error 13 on Access 2007 db VBA code

Posted on 2010-09-24
1
Medium Priority
?
303 Views
Last Modified: 2013-12-25
this is the module that gets Error 13, typ mismatch:

Function FindMax2()

    Dim db As DAO.Database
    Dim mx As Integer
    Dim rs As DAO.Recordset
    Dim rsVal As String
   
   
    Set db = CurrentDb()
    Set rs = db.OpenRecordset("UtilityPermit", dbOpenDynaset)
   
    rs.MoveFirst
   
   
    rsVal = rs.Fields("[UtilityPermitNumber]").Value
    mx = Right(rsVal, Len(rsVal) - 8)
   
    Do While Not rs.EOF
        rsVal = rs.Fields("[UtilityPermitNumber]").Value
        If Right(rsVal, Len(rsVal) - 8) > mx Then
        mx = Right(rsVal, Len(rsVal) - 8)
        End If
        rs.MoveNext
    Loop
    FindMax2 = "GRB10-U-" & (mx + 1)
End Function

and this is the utility permit numbers that have been generated from it:

UtilityPermitNumber
GRB10-U-1
GRB10-U-10
GRB10-U-11
GRB10-U-12
GRB10-U-13
GRB10-U-14
GRB10-U-15
GRB10-U-16
GRB10-U-17
GRB10-U-18
GRB10-U-19
GRB10-U-2
GRB10-U-20
GRB10-U-21
GRB10-U-22
GRB10-U-23
GRB10-U-24
GRB10-U-25
GRB10-U-26
GRB10-U-27
GRB10-U-28
GRB10-U-29
GRB10-U-3
GRB10-U-30
GRB10-U-31
GRB10-U-32
GRB10-U-33
GRB10-U-34
GRB10-U-35
GRB10-U-36 - REVISED
GRB10-U-37
GRB10-U-38
GRB10-U-39
GRB10-U-4
GRB10-U-40
GRB10-U-41
GRB10-U-42
GRB10-U-43
GRB10-U-44
GRB10-U-45
GRB10-U-46
GRB10-U-47
GRB10-U-48
GRB10-U-49
GRB10-U-5
GRB10-U-6
GRB10-U-7
GRB10-U-8
GRB10-U-9

at this point it will not add another record.  I get  a Run-tme error '13'.  can anyone help me with this code.  I know it is a minor problem, but I don't know exactly what.  Thanks.
0
Comment
Question by:GarfieldCO
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 93

Accepted Solution

by:
Patrick Matthews earned 2000 total points
ID: 33754708
Once you hit "GRB10-U-36 - REVISED" you will get a type mismatch: you won't be able to convert that text into an Integer :)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Suggested Courses

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question