If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Update a field for all records in a form
I have a form that has a textbox in the header that I populate with a value.
I'd like to have a command button that then updates a specific field for each record displayed on the form with that value. I've tried: Me.FieldName = Me.Textbox But this only updates the first record on the form. I know this is probably a simple process, but I just can't get my head in it. Thanks for any help -- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/For...forms/200911/1 |
#2
|
|||
|
|||
Update a field for all records in a form
On Tue, 03 Nov 2009 17:03:24 GMT, ondvirg via AccessMonster.com wrote:
I have a form that has a textbox in the header that I populate with a value. I'd like to have a command button that then updates a specific field for each record displayed on the form with that value. I've tried: Me.FieldName = Me.Textbox But this only updates the first record on the form. I know this is probably a simple process, but I just can't get my head in it. Thanks for any help Is the value a Text value or a Number value or a Date value. It does make a difference. 1) Forms don't actually 'contain' records. They simply display records. Tables contain records. 2) You can place code in a command button click event on the form that will actually update ALL the records in the table: CurrentDb.Execute "Update MyTable Set MyTable.[FieldName] = " & Me!ControlName The above assumes the [FieldName] datatype is a Number value. Text and dates require a different syntax. If the value is a Text datatype, then use: CurrentDb.Execute "Update MyTable Set MyTable.[FieldName] = """ & Me!ControlName & """" If is is a Data datatype, then: CurrentDb.Execute "Update MyTable Set MyTable.[FieldName] = #" & Me!ControlName & "#" Always indicate a field's datatype when asking for help. Always back up your table data first before trying new code. -- Fred Please respond only to this newsgroup. I do not reply to personal e-mail |
Thread Tools | |
Display Modes | |
|
|