Link to home
Create AccountLog in
Avatar of dougf1r
dougf1r

asked on

Command button to run two functions

I have a button that is supposed to 1) Run a Query 2) Export that query to Excel using a Module (code below)

However, I receive an error stating:
"The expression On Click you entered as the event property setting produced the folloiwng error: Ambiguous name detected: DLGrabQuery_Click"

If I remove the second sub-routine (last 4 lines) the query is executed ok. Is there something I am missing that will allow this button to carry out both sub's?

Option Compare Database

Private Sub DLGrabQuery_Click()
On Error GoTo Err_DLGrabQuery_Click

    Dim stDocName As String

    stDocName = "DL_Query_Grab"
    DoCmd.OpenQuery stDocName, acNormal, acEdit

Exit_DLGrabQuery_Click:
    Exit Sub

Err_DLGrabQuery_Click:
    MsgBox Err.Description
    Resume Exit_DLGrabQuery_Click
    
End Sub
Private Sub DLGrabQuery_Click()
Call ExportTable("DL_Query_Grab")
End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of dougf1r
dougf1r

ASKER

Thanks!