Results 1 to 2 of 2
  1. #1
    New Lounger
    Join Date
    Sep 2001
    Location
    Detroit, Michigan, USA
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    assign variable in Macro (2000 and up)

    I have a database that I import files to

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

    Re: assign variable in Macro (2000 and up)

    The target of a MakeTable query cannot be a variable name. You'd have to change the SQL text of the query, or assemble the SQL string and execute it. I would use VBA for this, not a macro (but you can call the VBA code from a macro if you wish).

    Sub MakeATable()
    Dim strName As String
    Dim strSQL As String
    strName = InputBox("Enter the name")
    If strName = "" Then
    MsgBox "No name specified.", vbCritical
    Exit Sub
    End If
    ' Just an example
    strSQL = "SELECT [Field1], [Field2], [Field3] INTO [F_" & strName & "] FROM CurList"
    DoCmd.RunSQL strSQL
    End Sub

Posting Permissions

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