updating field in a table which is not related to the open form.

  • Thread starter Thread starter Rani
  • Start date Start date
R

Rani

Hi guys,

I have a contract form where the user enters data.
I have few command buttons on the form and I want to change the status of
the car upon saving the new contract.
the status field is located in the car table,
how do I do that ?
 
You can code a command button to run an Update query on the car table and
set the status field accordingly.
I can't help too much with the actual code because I don't know your actual
field and table names nor the conditions upon which the change should be
made.

Here's an example.
If we assume [Status] is a CheckBox field, then you can use something like:
CurrentDb.Execute "Update CarTable Set CarTable.Status = True where
CarTable.RecordID = " & Me.RecordID & ";", dbFailOnError

The above assumes [RecordID] is a Number datatype.

An easy way to get the syntax and code correct is to actually make an Update
Query. When you get it to work correctly, simply copy the SQL to the above
form's command button's click event.
 
Hi Fred.
Thanks for your help, I do have few more questions in order to clarify
things.
1. I am using Adp file so the update queries are being handled a bit
differently.
2. I would appreciate if you could help me with the actual code as I am new
to writing store procedure.
the field I would like to update called "status" located in a table named
"Car_tbl"
3. The button to initiate the store procedure is located within a form named
"Choze_Frm"
and the, and the field that should trigger the process is the ChozeNum
(witch is chozeID)
4. Status - Char Field, ChozeNum is a numeric field.

if you could help me a bit further with that I would appreciate it very
much.


Fredg said:
You can code a command button to run an Update query on the car table and
set the status field accordingly.
I can't help too much with the actual code because I don't know your actual
field and table names nor the conditions upon which the change should be
made.

Here's an example.
If we assume [Status] is a CheckBox field, then you can use something like:
CurrentDb.Execute "Update CarTable Set CarTable.Status = True where
CarTable.RecordID = " & Me.RecordID & ";", dbFailOnError

The above assumes [RecordID] is a Number datatype.

An easy way to get the syntax and code correct is to actually make an Update
Query. When you get it to work correctly, simply copy the SQL to the above
form's command button's click event.
--
Fred

Please reply only to this newsgroup.
I do not reply to personal e-mail.


Rani said:
Hi guys,

I have a contract form where the user enters data.
I have few command buttons on the form and I want to change the status of
the car upon saving the new contract.
the status field is located in the car table,
how do I do that ?
 
Back
Top