I have a form with a field named ID. I need to store the value of that ID in a table called tblID in the field SID. tblID only has one record as it is temporary storage and gets replaced often.
Any help in writing the vba would be most appreciated.
I have a form with a field named ID. I need to store the value of that ID in a table called tblID in the field SID. tblID only has one record as it is temporary storage and gets replaced often.
Any help in writing the vba would be most appreciated.
My code is working somewhat. It works the 1st time I use the code. However, on the 2nd try it add a new record instead of replacing the value currently stored. I need it to replace the value SID. What am I doing wrong?
Code:DoCmd.OpenTable "tblID" CurrentDb.Execute "INSERT INTO tblID (SID) VALUES (" & ID.Value & ")"
Sounds like you want an update query instead of an append query.
What changes do I need to make to the code for an update query. I am very unfamiliar with VBA
Not really a VBA change, just an SQL change.
"UPDATE TableName SET FieldName = " Me.iD
Thank you for the suggestion but I do not know what to do with the code. I want the code to run when I click a command button. So exactly how and where do I use the code. Sorry to be so dense!
Code:Private Sub btn_printreceipt_Click() ??????? End Sub
That was a different query:
CurrentDb.Execute "UPDATE TableName SET FieldName = " Me.iD
will update the table as you want it to.Code:Private Sub btn_printreceipt_Click() Currentdb.execute "Update tblID set SID = " & me![ID] End Sub
(But you'll need more code to print anything...)
Thank you John and Paul. It now works perfectly. Such a simple answer.
Thanks again.
Judy