Results 1 to 10 of 10
  1. #1
    Join Date
    Oct 2010
    Posts
    162

    Event procedure coding

    Does anyone see anything wrong with this code?
    Private Sub AWC_EMPLOYEE_Click()
    On Error GoTo Err_AWC_EMPLOYEE_Click

    Dim stDocName As String

    stDocName = "Labels AWC Employees"
    DoCmd.OpenReport stDocName, acPreview

    Exit_AWC_EMPLOYEE_Click:
    Exit Sub

    Err_AWC_EMPLOYEE_Click:
    MsgBox Err.Description
    Resume Exit_AWC_EMPLOYEE_Click

    End Sub

    This code is used to open address labels based off of a query. It was working fine until yesterday. I think I may have messed something up. Any help is greatly appreciated!

  2. #2
    Join Date
    Oct 2003
    Location
    London
    Posts
    327
    DoCmd.OpenReport stDocName, acViewPreview

  3. #3
    Join Date
    Oct 2010
    Posts
    162
    Ok I'll try it.

  4. #4
    Join Date
    Oct 2010
    Posts
    162
    I tried changing just that portion of the coding, and still got the same error message. The message I'm receiving is as follows:

    "The expression On Click you entered as the event property setting produced the following error: Ambiguous name detected: AWC_Employee_Click."
    *The expression may not result in th ename of a macro, th ename of a user-defined function, or [Event Procedure].
    *There may have been an error evaluating the function, event, or macro.

    When I clicked help on this error, the message is as follows:
    This error occurs when an event has failed to run because the location of the logic for the event cannot be evaluated. For example, if the OnOpen property of a form is set to =[Field], this error occurs because a macro or event name is expected to run when the event occurs.

  5. #5
    Join Date
    Oct 2010
    Posts
    162
    Apparently this error occurs when there are multiple procedures with the same name in a module.

    I don't know what this means.

  6. #6
    Join Date
    Oct 2010
    Posts
    162
    Never mind! I got it!

  7. #7
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    12,567
    it helps others if you say what you found resolved the problem
    I'd rather be riding on the Tiger 800 or the Norton

  8. #8
    Join Date
    Oct 2010
    Posts
    162
    I thought I did that in my last post, but not enough info...sorry.

    open the form in design view

    click view code in the tools group on the design tab

    click debug

    click compile database name

    when you receive the error message, click ok

    in the code, find the duplicate procedures and delete them.

    Hope this is more helpful.

  9. #9
    Join Date
    Oct 2003
    Location
    London
    Posts
    327
    All it looks like is that you had two procedures of multiple names.
    If you recieve errors like this in future, put the actual error message up. we could have resolved it straight away

    Glad it works now.

  10. #10
    Join Date
    Oct 2010
    Posts
    162
    I did put the actual error code up, see post #4.

    Thanks again for your help!

Posting Permissions

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