Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Aug 2001
    Location
    Cape Town, South Africa, South Africa
    Posts
    399
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Fixing code (Access 2000)

    Please help with this syntax. I lost it:

    Function EmailAccToDoug()
    Dim Tblnames(15) As String
    Dim querydet As String

    Tblnames(1) = "Acc212120"
    Tblnames(2) = "Acc212130"
    Tblnames(3) = "Acc212140"
    Tblnames(4) = "Acc212150"
    Tblnames(5) = "Acc212160"
    Tblnames(6) = "Acc212310"
    Tblnames(7) = "Acc212320"
    Tblnames(8) = "Acc212330"

    For a = 1 To 8

    querydet = Chr(34) & Right(Tblnames(a), 6) & Chr(34)

    DoCmd.RunSQL "SELECT * into & TblNames(a) & FROM [Union 1999] WHERE Account=" & querydet & ";"

    Next a


    End Function


    Thanks

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

    Re: Fixing code (Access 2000)

    You forgot two essential quotes in the DoCmd.RunSQL line. A good way to find out what's going on is temporarily replacing DoCmd.RunSQL by MsgBox or Debug.Print; you will see the SQL string that causes the error. The line should be

    DoCmd.RunSQL "SELECT * into " & Tblnames(a) & " FROM [Union 1999] WHERE Account=" & querydet & ";"

  3. #3
    3 Star Lounger
    Join Date
    Aug 2001
    Location
    Cape Town, South Africa, South Africa
    Posts
    399
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Fixing code (Access 2000)

    Thanks for the code & great tip on debugging. Haven't thought about that trick.

Posting Permissions

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