Results 1 to 2 of 2
  1. #1
    2 Star Lounger
    Join Date
    Mar 2004
    Portland, Oregon
    Thanked 0 Times in 0 Posts

    Runtime error '2001' (2002)

    (Indentation restored by inserting <!t>[tab]<!/t> tags - Mod)

    Basically I'm incrementing a number to create a "client ID" Here is my code:

    <code>Private Function BatesIncrementNumber() As String</code>

    <code> Dim lNextNumber As Long</code>
    <code> Dim sYear As String</code>
    <code> Dim sClient As String ' Pass the Client number from the table</code>
    <code> Dim sClientNo As String</code>
    <code> Dim sFormat As String</code>
    <code> Dim sPrefix As String ' Prefex is the Client number stored in the table</code>
    <code> Dim Msg, Style, Title, Help, Ctxt, Response, MyString</code>

    <code> ' Establishes the Prefix for the number output.</code>
    <code> ' Office staff will be adding to this table.</code>
    <code> sFormat = "00000"</code>
    <code> sPrefix = Me.txtYrOpen & Me.cboClientTYP</code>

    <code> lNextNumber = DMax("<!t>[anNumberMax]<!/t>", "qryIncrementNo", "<!t>[anClaimType]<!/t>=" & "'" & Me.cboClientTYP & "'") + 1</code>

    <code> With DoCmd</code>
    <code> .SetWarnings False</code>
    <code> .RunSQL "UPDATE tblAutoNumber " & _</code>
    <code> "SET anNumberMax = " & lNextNumber & _</code>
    <code> " WHERE tblAutoNumber.anClaimType = '" & Me.cboClientTYP & "'"</code>

    <code> .SetWarnings True</code>
    <code> End With</code>

    <code> 'Enters the File Number according to the variables.</code>
    <code> txtFileNumber = sPrefix & "-" & Format(lNextNumber, sFormat)</code>

    <code>End Function</code>

    I'm getting the attached error message at this line:

    lNextNumber = DMax("[anNumberMax]", "qryIncrementNo", "[anClaimType]=" & "'" & Me.cboClientTYP & "'") + 1

    I have no idea what this is and if I click "help" in the error message box, I don't get any help.
    So, any help out there?
    Attached Files Attached Files

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Thanked 31 Times in 31 Posts

    Re: Runtime error '2001' (2002)

    You will get this error message in the following circumstances:
    - There is an error in the field name <code>anNumberMax</code>.
    - There is an error in the field name <code>anClaimType</code>
    - The query <code>qryIncrementNo</code> is a parameter query (DMax and related functions can't handle parameter queries)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts