A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Update a field for all records in a form



 
 
Thread Tools Display Modes
  #1  
Old November 3rd, 2009, 05:03 PM posted to microsoft.public.access.forms
ondvirg via AccessMonster.com
external usenet poster
 
Posts: 8
Default 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  
Old November 3rd, 2009, 05:42 PM posted to microsoft.public.access.forms
fredg
external usenet poster
 
Posts: 4,386
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 02:46 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.