VB code error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Bface
    New Member
    • Nov 2006
    • 14

    VB code error

    Hi All,

    I have received help before; hopefully someone will be able to help me out. I have a combo box [ComboActivity] on my main form [Main Acct Details], once the selection is made I would like for the account to append to another table. The source for the Main form is a query [Qry SP ALL]. I wrote the VB code below but I received this error ‘Run-time erro ‘3134’: Syntax error in INSERT INTO statement’
    Could someone please look at it and tell me what I did wrong.

    Code:
    Private Sub ComboActivity_A fterUpdate()

    DoCmd.SetWarnin gs False

    mySQL = "INSERT INTO Tbl_AcctWcodes ([Acct#],PT_Name, Acct_Bal, Pt_Status, FC, SC, ComboActivity) Select [forms]![Main Acct Details]![ACCT#] as a, [forms]![Main Acct Details]![PATIENT NAME] as b, [forms]![Main Acct Details]![ACCT BAL] as c, [forms]![Main Acct Details]![S] as d, [forms]![Main Acct Details]![F_C] as e, [forms]![Main Acct Details]![S/C] as f, [forms]![Main Acct Details]![ComboActivity] as g, FROM [forms]![Main Acct Details];"
    DoCmd.RunSQL mySQL

    DoCmd.RepaintOb ject acForm, "Main Acct Details"
    Forms![Main Acct Details]!ComboActivity = Null

    End Sub
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32633

    #2
    You have an extraneous comma before your FROM keyword.
    To find this easily, I copied your string into an empty query SQL window and it gave me the error message and highlighted the FROM.
    From there it was easy to see the problem.

    Comment

    • Bface
      New Member
      • Nov 2006
      • 14

      #3
      Thank you NeoPa, I got it to work.

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32633

        #4
        No Problem.
        We're here to help :)

        Comment

        • Bface
          New Member
          • Nov 2006
          • 14

          #5
          Hi NeoPa,

          Everything is working great. I have a quick question, instead of appending the record, is there a VB code that I can use to hide the account or filter it from the form? I am only appending it because that is the only way I know for the account to no longer be available to the user. I was just wondering, thanks again for your help.

          Comment

          • NeoPa
            Recognized Expert Moderator MVP
            • Oct 2006
            • 32633

            #6
            I don't really know enough about what you're trying to do to advise here.
            Do you want it to be unavailable permanently, or just for the current session.
            An array might work (if a bit more complicated to set up) if the latter.
            Otherwise storing it in a table is probably the best solution.

            Comment

            Working...