Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2003
    Posts
    126

    Red face Unanswered: Pass Variable to Macro

    Hi ya!

    I have a need to pass a macro a variable, how can I accomplish this?

    Code:
    Private Sub Command20_Click()
    On Error GoTo Err_Command20_Click
    
        Dim stDocName As String
    
        stDocName = "Macro2"
        DoCmd.RunMacro stDocName
    
    Exit_Command20_Click:
        Exit Sub
    
    Err_Command20_Click:
        MsgBox Err.Description
        Resume Exit_Command20_Click
        
    End Sub
    This is a "Transfer Spreadsheet" Macro

    I want my Variable to set the "File Name"

    Thanks much!

    Ken

  2. #2
    Join Date
    Jul 2002
    Location
    Romania
    Posts
    122
    Why do you want to run a macro from code??? There is a
    DoCmd.TransferSpreadsheet method which could accomplish what you need even better (error control, variable transfers and so on).

    HTH

    Dan

  3. #3
    Join Date
    Jan 2003
    Posts
    126
    Never thought of that, I'll have to check it out!

    Anyone have a good example of this?

  4. #4
    Join Date
    Jan 2003
    Posts
    126
    Originally posted by GA_KEN
    Never thought of that, I'll have to check it out!

    Anyone have a good example of this?
    I figured it out! Thanks!

Posting Permissions

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