简体   繁体   中英

Update specific record in table with form?

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM