Results 1 to 12 of 12
  1. #1
    Join Date
    Sep 2003
    Location
    Washington, DC
    Posts
    116

    Unhappy Unanswered: Compile error: label not defined

    I keep getting an error on this code that says Compile error: label not defined. Can you help?

    Private Sub cmdNewTerm_Click()
    On Error GoTo Err_cmdNewTerm_Click
    Dim Account

    'get the record id and form
    glbAccount = Nz(Me.FACCKEY, 0)
    'close the new account form
    DoCmd.Close
    'open the form
    DoCmd.OpenForm "frm01TerminationLog"

    Err_cmdNewTerm_Click:
    MsgBox Err.Description
    Resume Exit_cmdNewTerm_Click

    End Sub

  2. #2
    Join Date
    Jan 2004
    Location
    The Netherlands
    Posts
    421
    Resume Exit_cmdNewTerm_ClickThere is your problem, you have no line:
    Exit_cmdNewTerm_Click:

    For every goto and Resume etc. you need to define the name thats behind it.

    Greetz

  3. #3
    Join Date
    Sep 2003
    Location
    Washington, DC
    Posts
    116
    Thanks. I'm still getting a compile error.

    Private Sub cmdNewTerm_Click()
    On Error GoTo Err_cmdNewTerm_Click
    Dim Account

    'get the record id and form
    glbAccount = Nz(Me.FACCKEY, 0)
    'close the new account form
    DoCmd.Close
    'open the form
    DoCmd.OpenForm "frm01TerminationLog"

    Err_cmdNewTerm_Click:
    MsgBox Err.Description
    Resume Exit_cmdNewTerm_Click

    Exit_cmdNewTerm_Click

    End Sub

  4. #4
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    And what is the error this time?

  5. #5
    Join Date
    Sep 2003
    Location
    Washington, DC
    Posts
    116
    Compile error: sub or function not defined.

  6. #6
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    You forgot the : after the
    Exit_cmdNewTerm_Click
    It should be
    Exit_cmdNewTerm_Click:

  7. #7
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    I mean the last sentence before the End Sub

  8. #8
    Join Date
    Sep 2003
    Location
    Washington, DC
    Posts
    116
    Thanks! I figured it went there. Now I'm getting a type mismatch error, when running this but I have no clue why I would. The glbAccount is public. Basically what's supposed to happen is when this button is clicked, it dim's the account number and returns that value in another form.

  9. #9
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    Try to define the glbAccount as Variant

  10. #10
    Join Date
    Sep 2003
    Location
    Washington, DC
    Posts
    116
    Alright, that worked, but a weird thing happens now. When the new form opens what looks like an error box pops up, but there's no text in it. When I hit okay, another one comes up that says resume without error. On load code:

    Private Sub Form_Load()
    Me.AccountNo = glbAccount
    End Sub

  11. #11
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    Quote Originally Posted by PatrickFAO
    Thanks. I'm still getting a compile error.

    Private Sub cmdNewTerm_Click()
    On Error GoTo Err_cmdNewTerm_Click
    Dim Account

    'get the record id and form
    glbAccount = Nz(Me.FACCKEY, 0)
    'close the new account form
    DoCmd.Close
    'open the form
    DoCmd.OpenForm "frm01TerminationLog"

    GOTO Exit_cmdNewTerm_Click

    Err_cmdNewTerm_Click:
    MsgBox Err.Description
    Resume Exit_cmdNewTerm_Click

    Exit_cmdNewTerm_Click

    End Sub
    You have to add the blue Statement
    I know it is Orange

  12. #12
    Join Date
    Sep 2003
    Location
    Washington, DC
    Posts
    116
    You are awesome!!! Thanks!!!

Posting Permissions

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