Results 1 to 3 of 3
  1. #1
    TinaCa is offline Advanced Beginner
    Windows Vista Access 2010 32bit
    Join Date
    Jul 2011
    Posts
    87

    Overflow Error when converting data types

    I need to concatenate a year to an invoice number. Steps are get most recent invoice number for this year and assign to variable.



    InvCurr = rs.Fields("InvoiceId") It comes in as a string. then I use left() to get the actual invoice Id (without the two numbers on the end that are the year).

    Now here is my code to increase the invoice number by and then concatenate the year to it.

    Dim InvCurr As String
    Dim InvNo As Integer
    Dim InvNoU As String
    Dim InvNoIn As Integer

    InvNo = CInt(InvCurr + 1)
    InvNoU = CStr(InvNo) & InvNoYr
    InvNoIn = CInt(InvNoU)


    The first two run great when i get to the third one InvNoIn I get an overflow error what is making this one different from the others? (I tried using variant and it didn't help)

    Tina

  2. #2
    AMAS is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2012
    Posts
    10
    Hi Tina,

    Excel vba is more of my thing, but I would guess that InvNoU is not an integer stored as a string. You can see what the variable contains in the immediate window using

    Code:
    Deubug.print InvNoU
    This should appear to be an integer, if not then InvNoIn is going to error out.

  3. #3
    TinaCa is offline Advanced Beginner
    Windows Vista Access 2010 32bit
    Join Date
    Jul 2011
    Posts
    87
    I changed the variable type to variant and now it is working perfect. Thanks

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

Similar Threads

  1. OVERFLOW error in both Query and Report
    By LanieB in forum Access
    Replies: 9
    Last Post: 11-11-2011, 08:54 PM
  2. OverFlow Error.
    By Coffee in forum Import/Export Data
    Replies: 5
    Last Post: 08-17-2011, 05:44 PM
  3. Overflow error - change field type in query?
    By Lady_Jane in forum Queries
    Replies: 6
    Last Post: 05-25-2011, 01:10 PM
  4. Replies: 2
    Last Post: 12-03-2009, 05:06 PM
  5. Run time error '6': Overflow
    By wasim_sono in forum Access
    Replies: 0
    Last Post: 06-22-2007, 06:44 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