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

Append query

P: 24
Hi guys,

Hopefully I am not asking for to much here. On my main form [Patients], its source is from a qry [Qry_All_Patients], which is created from table[Tbl_All_Patients]. I would like to add a combo box [cboOption] which has 2 choices. They are review & completed.
Is there a simple code I can enter in the AfterUpdate of the combo box which will append the [Acct#, PTname, PTFNCLS] from the main form to a table.
I have done append queries before but that appends alll the accounts.

Thank you again for any help anyone can provide.
Nov 27 '06 #1
Share this Question
Share on Google+
4 Replies


PEB
Expert 100+
P: 1,418
PEB
So if you want to append only the current record you should specify a complementary line

WHERE (ID="+str(Me!ID)+");"

Or if there is no query based on a table you have only specify a table where add the information

just like:

INSERT INTO mylove(A,b,C)
SELECT "Judie" AS A , "Angelika" AS B, "Susie" AS C;

Without mention anything else

And just one record with those names will be insertted!
;)
Nov 27 '06 #2

P: 24
HI PEB,

Thanks for replying, you have to forgive me but my vb programming skills is not good at all. Please be patient with me. I enter the code below into the AfterUpdate event of the combo box but it did not work. If you coud please look at it and tell me what needs to be changed.

Private Sub cboOption_AfterUpdate()

DoCmd.RunSQL "INSERT INTO Tbl_Analysis(ACCT#, PTName, PTFNCLS, Activity_code)
SELECT “ACCT#” AS ACCT#, “PATIENT NAME” AS PTName, “F_C” AS PTFNCLS, “cboOption” AS Activity_code;"

End Sub

Thanks for all your help.
Nov 27 '06 #3

PEB
Expert 100+
P: 1,418
PEB
HI PEB,

Thanks for replying, you have to forgive me but my vb programming skills is not good at all. Please be patient with me. I enter the code below into the AfterUpdate event of the combo box but it did not work. If you coud please look at it and tell me what needs to be changed.

Private Sub cboOption_AfterUpdate()

DoCmd.RunSQL "INSERT INTO Tbl_Analysis([ACCT#,] [PTName], [PTFNCLS], [Activity_code])
SELECT “+str(Me![ACCT#])+” AS ACCT#, '“+me![PATIENT NAME]+”' AS PTName, '“+me![F_C]+”' AS PTFNCLS, '“+me!cboOption+”' AS Activity_code;"

End Sub

Thanks for all your help.
I suppose that

Me![ACCT#] is a field in your form and it is a number
The next fields are also fields from your form but are string /text so u see what happens with the string

As your SQL is a string you need to add the corresponding strings

To refer to your strings in form in the current form i use Me![Field] as u noticed!

:)
Nov 27 '06 #4

P: 24
Thanks PEB for all your help. I think I got it.
Nov 28 '06 #5

Post your reply

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