By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,841 Members | 1,757 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,841 IT Pros & Developers. It's quick & easy.

VB code error

P: 14
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.

Private Sub ComboActivity_AfterUpdate()

DoCmd.SetWarnings 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.RepaintObject acForm, "Main Acct Details"
Forms![Main Acct Details]!ComboActivity = Null

End Sub
Dec 4 '06 #1
Share this Question
Share on Google+
5 Replies

Expert Mod 15k+
P: 31,660
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.
Dec 4 '06 #2

P: 14
Thank you NeoPa, I got it to work.
Dec 6 '06 #3

Expert Mod 15k+
P: 31,660
No Problem.
We're here to help :)
Dec 6 '06 #4

P: 14
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.
Dec 6 '06 #5

Expert Mod 15k+
P: 31,660
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.
Dec 6 '06 #6

Post your reply

Sign in to post your reply or Sign up for a free account.