Hi
is it possible to make a button that fills a field in a table .
so when i press the Button it should put a text into a field in my table.
thanks
Hi
is it possible to make a button that fills a field in a table .
so when i press the Button it should put a text into a field in my table.
thanks
Assuming the table to be updated is the record source for the form, and that the field to be updated is a control on the form, it's easily done with VBA.
Use the On Click event of the button to add the text to the form field:
Me![myformcontrol] = "Some text..."
It's a bit trickier if the table to be updated is not the form recordsource, but it's still easy.
Hi thank you very much
the table isnīt the form recordsource so what should i do
OK - you will have to use SQL to update the relevant table, but you will need some additional information to identify which record in the table is to be updated, in addition to the new value.
You would do something like this, again in the On Click event:
Where:Code:Dim SQL as string SQL = "Update tablename set fieldname1= 'some text...' where fieldname2 = " & me![formcontrol] currentdb.execute SQL, dbfailonerror
tablename is the table containing the record to be updated
fieldname1 is the field in that table
fieldname2 is the field in the table which (presumably) uniquely identifies the records in the table (e.g. the PK)
formcontrol is a form field containing a value which identifies the record to be updated
It also assumes that the text value to use for the update is the same each time. If not, i.e. you type in the new text, the SQL = ... statement will be a bit different.
thank you very much but what does this mean "fieldname2 is the field in the table which (presumably) uniquely identifies the records in the table (e.g. the PK)
formcontrol is a form field containing a value which identifies the record to be updated"
Use your actual field and control names in place of the dummy examples.
You need some sort of filter parameter(s) to identify which record(s) in table to update. What information is on the form that can be used to identify records? If you want ALL records to have the same value then don't need filter parameter.
But maybe 'put a text into a field' means you want to add NEW RECORDS?
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
A SQL update statement will update all the records in the table, unless you use a WHERE clause to identify which specific record(s) you need to update.
The table to be updated must have a field which can be used to identify the records (usually this will be the PK). So, when you click that update button, you need to have a value somewhere (a control value on your form) that you can use to identify which record is to be updated. Do you have such a control on your form?
So it is like you have 3 Buttons and a Table with 3 lines with different Names 1,2,3 if you put button 1 then put in line 1 yes. if you put button 2 then put in line 2 yes.
sorry for my english
A table that has only 3 records? And will always have these 3 records?
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.