Reputation: 25
I built a database for a fleet of trucks. One of my forms allows the user to enter a new job that was done to a truck. One of these fields is 'kilomètres' (miles)
To be short, I want the 'Kilomètres' field in the 'new job' form to update the 'Kilomètres' field in the table but only for the specified vehicles.
In VBA I tried both of these (these codes are run with the click of a button):
UPDATE véhicules : infos particulières ' (which is the table name)
SET Kilomètres = [Kilomètres]
WHERE [Véhicules] = Véhicules
OR something like this :
[Véhicules : infos particulièrs].Kilomètres = Kilomètres
but than I don't know how to refer to the specific record...
Any help is appreciated
Upvotes: 1
Views: 876
Reputation: 61
Use
"UPDATE [Véhicules : infos particulières] SET Kilomètres = " & Me.txtKilomètres] & " WHERE [Véhicules] = " & Me.txtVéhicules
as SQL string in vba, if Véhicules is a number. else add qoutes.
txtKilomètres
and txtVéhicules
are the names of the controls of the form.
if vba-code is not inside the form, you have referer to the form by formname
Avoid accents and other special characters, use _
instead of spaces
Upvotes: 2