Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    Nov 2002
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Running an append query from a conditional macro (Access 2000)

    I need to execute an append query from a conditional macro. I know that I need to use "run SQL" from do.cmd in VB, but I am not quite sure how to arrange the syntax to get this to happen. The SQL is over 256 characters so I know I can't use the run SQL command from the macro and I need to use run code. I'm sure this isn't too complicated, but my VB knowledge is limited.
    Any help with this would be greatly appreciated. Thanks

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Running an append query from a conditional macro (Access 2000)

    If you can store the append query, you can use the OpenQuery action with the name of the stored query as argument.

    If you need to construct the SQL on the fly, you can create a function in a standard module:

    Function RunMySQL()
    Dim strSQL As String
    strSQL = ... ' construct your SQL string here; it can be over 256 characters
    DoCmd.RunSQL strSQL ' or CurrentDb.Execute strSQL
    End Function

    You can call this function in a macro with the RunCode action; enter RunMySQL() as argument.

  3. #3
    New Lounger
    Join Date
    Nov 2002
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Running an append query from a conditional macro (Access 2000)

    Hans,

    Thank you for your response to my "Running SQL from Macros" problem. It seems to have done the trick.
    Thanks again for your time.

    Jon

Posting Permissions

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