Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Writing the same Data to 2 tables

Status
Not open for further replies.

awsomedm

Technical User
Oct 26, 2010
2
US
I have a form that puts data in a table "Service". after that data is put into it's table I would like one of those values "currentmiles" to be written to a seperate table "Vehicle" in the field "milage". Can anyone help me?
 
Something like this:

Code:
Dim strSQL As String

strSQL = "INSERT INTO Vehicle ( Mileage )
Values(" & Me.YourFormControlWithTheMileage & ")"

CurrentDb.Execute strSQL, dbFailOnError

Bob Larson
Free Access Tutorials and Samples:
 
Thank you very much for your help.
The row in Vehicle already exists so I guess I want to do an Update. when I saw your reply I started searching more about it and found the Update. I am trying to figure out how to put this into my VBA code in Access. I should have mentioned that the row I want to edit is based on vehicleID.
 
So instead it would be:
Code:
Dim strSQL As String

strSQL = "UPDATE Vehicle SET Mileage =" & Me.YourFormControlWithTheMileage & _
" WHERE VehicleID = " & Me.YourControlWithVehicleID

CurrentDb.Execute strSQL, dbFailOnError

If VehicleID is text then you would need quotes:

Code:
Dim strSQL As String

strSQL = "UPDATE Vehicle SET Mileage =" & Me.YourFormControlWithTheMileage & _
" WHERE VehicleID = " & Chr(34) & Me.YourControlWithVehicleID & Chr(34)

CurrentDb.Execute strSQL, dbFailOnError

Bob Larson
Free Access Tutorials and Samples:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top