military donut
asked on
public sub module, passing data to table
Hello,
I would like to use the following sub routine to take data from a field on a form and pass the data to the table:
Public Sub VGTruck(Driver1_FName As String, Driver1_LName As String)
CurrentDb.Execute "INSERT INTO VGTruckProcessing (Driver1_FName, Driver1_LName) Values ('" & Driver1_FName & "','" & Driver1_LName & " ')"
End Sub
This is on my form that I want to pass the data to
trkproc.VGTruck (me.Name1 , me.Name2)
I want the data from the control, I tried using "Driver1_FName as Control" but that is wrong too. Don't know what I should use here.
I would like to use the following sub routine to take data from a field on a form and pass the data to the table:
Public Sub VGTruck(Driver1_FName As String, Driver1_LName As String)
CurrentDb.Execute "INSERT INTO VGTruckProcessing (Driver1_FName, Driver1_LName) Values ('" & Driver1_FName & "','" & Driver1_LName & " ')"
End Sub
This is on my form that I want to pass the data to
trkproc.VGTruck (me.Name1 , me.Name2)
I want the data from the control, I tried using "Driver1_FName as Control" but that is wrong too. Don't know what I should use here.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Try:
Module:
Above code was modified from the following tested code using Table1 (Gender, DG)
Form fields are f1, f2.
Module:
Module:
Public Sub VGTruck(Driver1_FName As String, Driver1_LName As String)
CurrentDb.Execute "INSERT INTO VGTruckProcessing (Driver1_FName, Driver1_LName)
Values ( '" & Driver1_FName & "','" & Driver1_LName & "')"
End Sub
Calling from a button in form: Private Sub Command4_Click()
VGTruck Me.Driver1_FName , Me.Driver1_LName
End Sub
Above code was modified from the following tested code using Table1 (Gender, DG)
Form fields are f1, f2.
Module:
Public Sub VGTruck(Driver1_FName As String, Driver1_LName As String)
CurrentDb.Execute "INSERT INTO Table1 (GENDER, DG) Values ( '" & Driver1_FName & "','" & Driver1_LName & "')"
End Sub
Calling from a button in form: f1 input value for FName, f2 input value for LNamePrivate Sub Command4_Click()
VGTruck Me.f1, Me.f2
End Sub
ASKER
but changed to this...and works perfectly.
Thanks!