Taking data from form and placing into table

johnbongrovey

New member
Local time
Today, 07:18
Joined
Nov 21, 2013
Messages
9
I have a form that I am inputting data into. I have been able to Clear the form. I have created an edit script and it brings the data from the table to populate the form. When I try to change the data in the form and run a VBA update to push the data down to the table I am having no luck. I can add/Delete recordswith no problems but I can't edit them and put them back in the table. I am novice and just learning the formats and scripting.
 
I am taking the tblvehicle and trying to take the variable's from the form and put into the table.
Private Sub Update_Click()
CurrentDb.Execute "update tblVehicle " & _
" set Me.txtUnitNum =" & UnitNumber & _
", Department ='" & Me.cboDepartment & "'" & _
", VehicleType ='" & Me.cboVehicleType & " '" & _
"Where UnitNumber =" & Me.UnitNumber.Tag
'clear Form
cmdClear_Click
'refresh data in list on form
frmVehicleSub.Form.Requery
End Sub
 
The only thing that I really want to do is to take a record in a table and update the data from the form data that I put in. I am struggling with something that I would think would be simple. I am using Unbound fields in my form and I have a primary key in my table. I would like to select the record in the table and put the data from the form into that selected record.
 
Like I said, using unbound form is more difficult, but that said your methodology is fine, you just have to find the error in the SQL.
 
Thanks Paul I found the issue with my "Where statement"
Changed from:
"Where UnitNumber =" & Me.UnitNumber.Tag
Changed to:
WHERE UnitNumber =" & Me.txtUnitNum.Tag
I was using the UnitNumber on both ends of the statement
Thanks again for your assistance with this issue
 
Happy to help. Still confused by using the Tag property, but as long as it's working.
 

Users who are viewing this thread

Back
Top Bottom