kenzo
12-11-2018, 01:17 PM
I've made a form with some buttons
Now on every click on a button, I use the name of the button, to insert that into a table
But my syntax won't work.... what's wrong with it .... 23391
This is the code I use :
Private Sub JUPILER_Click()
Dim artikelnummer As Integer
Dim drank As String: drank = Me.ActiveControl.Name
MsgBox ("naam van het artikel = " & drank)
artikelnummer = DLookup("[ID]", "tbl_artikelen", "ucase([omschrijving]) ='" & drank & "'")
MsgBox (drank & " heeft als artikelnummer " & artikelnummer)
' gegevens in tabel ingeven
Dim db As Database
Dim rec As Recordset
Set db = CurrentDb
Set rec = db.OpenRecordset("Select * from tbl_bestelbon")
rec.AddNew
rec("omschrijving") = artikelnummer
rec("aantal") = 1
rec.Update
Set rec = Nothing
Set db = Nothing
End Sub
It doesn't give me an error ...
but there is no new record.
What am I doing wrong?
tnx for your advice
Now on every click on a button, I use the name of the button, to insert that into a table
But my syntax won't work.... what's wrong with it .... 23391
This is the code I use :
Private Sub JUPILER_Click()
Dim artikelnummer As Integer
Dim drank As String: drank = Me.ActiveControl.Name
MsgBox ("naam van het artikel = " & drank)
artikelnummer = DLookup("[ID]", "tbl_artikelen", "ucase([omschrijving]) ='" & drank & "'")
MsgBox (drank & " heeft als artikelnummer " & artikelnummer)
' gegevens in tabel ingeven
Dim db As Database
Dim rec As Recordset
Set db = CurrentDb
Set rec = db.OpenRecordset("Select * from tbl_bestelbon")
rec.AddNew
rec("omschrijving") = artikelnummer
rec("aantal") = 1
rec.Update
Set rec = Nothing
Set db = Nothing
End Sub
It doesn't give me an error ...
but there is no new record.
What am I doing wrong?
tnx for your advice