G
Guest
Hi there,
I have a form based on tblGetApps with a list box (lstApps). The list box
will have several entries depending on what is chosen in a combo box. What I
need to do is have EmpId and Machine (all text fields) and everything in the
list box inserted into the tblGetApps table.
Private Sub cmdAdd_Click()
Dim db As Database
Set db = CurrentDb
db.Execute "INSERT INTO tblGetApps ( EMPLID, Machine, Apps ) & _
"Values (EmplId, Machine, lstApps)"
set db = Nothing
I get a syntax error and am not sure what is wrong with my query formation.
I have also tried:
Private Sub cmdAdd_Click()
Dim db As Database
' Dim rs As Recordset
Dim App as String
Set db = CurrentDb
' Set rs = db.OpenRecordset("tblGetApps")
' App = Me.lstApps.Value
'
'
' rs.AddNew
' rs![EmplId] = EmplId
' rs![Machine] = Machine
' rs![Apps] = App
' rs.Update
'
rs.Close: Set rs = Nothing
Set db = Nothing
End Sub
This works, sort of but will only insert the one item I have clicked on in
the list box, otherwise it just inserts the two items in the text boxes and
leaves Apps blank. What can I do to fix this so that everything from the
list box gets inserted?
Thanks,
All help immensely appreciated!
I have a form based on tblGetApps with a list box (lstApps). The list box
will have several entries depending on what is chosen in a combo box. What I
need to do is have EmpId and Machine (all text fields) and everything in the
list box inserted into the tblGetApps table.
Private Sub cmdAdd_Click()
Dim db As Database
Set db = CurrentDb
db.Execute "INSERT INTO tblGetApps ( EMPLID, Machine, Apps ) & _
"Values (EmplId, Machine, lstApps)"
set db = Nothing
I get a syntax error and am not sure what is wrong with my query formation.
I have also tried:
Private Sub cmdAdd_Click()
Dim db As Database
' Dim rs As Recordset
Dim App as String
Set db = CurrentDb
' Set rs = db.OpenRecordset("tblGetApps")
' App = Me.lstApps.Value
'
'
' rs.AddNew
' rs![EmplId] = EmplId
' rs![Machine] = Machine
' rs![Apps] = App
' rs.Update
'
rs.Close: Set rs = Nothing
Set db = Nothing
End Sub
This works, sort of but will only insert the one item I have clicked on in
the list box, otherwise it just inserts the two items in the text boxes and
leaves Apps blank. What can I do to fix this so that everything from the
list box gets inserted?
Thanks,
All help immensely appreciated!