Macro Help

  • Thread starter Thread starter micktic
  • Start date Start date
M

micktic

Guest
Writing a simple Macro to run a select query with a parameter. The macro is executed through a form. When the macro kicks off, the 'Enter Parameter Value' box pops up. If you press cancel on the parameter box, an Action Failed pop up appears to halt the macro. How do you prevent this from appearing if you press cancel on the 'Enter Parameter Value' Box??

Help!
 
This might not be possible. You may need to use VBA instead.

str = InputBox("Give parameter:")
If Len(str) > 0 Then
strSQL = "SELECT * FROM table WHERE field=" & str
CurrentDb.QueryDefs("qry").SQL = strSQL
DoCmd.OpenQuery("qry")
End If

That should work. It assumes that you have a query called qry.
 

Users who are viewing this thread

Back
Top Bottom