combining the contents of a button

  • Thread starter Thread starter Al V
  • Start date Start date
A

Al V

I have one button that is running a SQL statement, and one
running a macro.

How do I combine the 2 to one button so the one button
executes both.

Thanks
AL
 
Al,

Assuming that "running a SQL statement" means ina VBA procedure, I
think these are your options:
1. Re-write the macro in VBA, and include it in the existing code
2. Re-write the code as a macro, and include it in the existing macro
3. Use a DoCmd.RunMacro line in the existing VBA code
4. Convert the VBA procedure to a function, and use a RunCode action
in the existing macro.

- Steve Schapel, Microsoft Access MVP
 
Steve,
Any idea how I would be able to get the following into a
macro:

Private Sub Command11_Click()
On Error GoTo Err_Command11_Click

Dim stDocName As String

stDocName = "append to main data table"
DoCmd.OpenQuery stDocName, acNormal, acEdit

Exit_Command11_Click:
Exit Sub

Err_Command11_Click:
MsgBox Err.Description
Resume Exit_Command11_Click

End Sub

Thanks
Al
 
Al,

Just use an OpenQuery action in the macro, and nominate your 'append
to main table data' query in the Query Name argument of the macro.
You might also want to put a SetWarnings,No action in the macro before
the OpenQuery action, to suppress the display of the action query
confirmation messages (after you are sure the query is working
properly, of course!)

- Steve Schapel, Microsoft Access MVP
 
Back
Top