A couple of issues:
- Klantnaam is declared as 'Integer' but you are assigning the value of a textbox to it. Maybe Access will coerce the textbox contents to an Integer but I doubt it. The line 'klantnaam = txtKlantnaam.Text' will probably throw an error unless Klantnaam is declared as a string
- You cannot access the .Text property of a control in Access unless that control has focus. Use the .Value property if you do not want to set focus to the control first.
- rst & db are Objects, to destroy them you must use the Set keyword.
Your original code updated:
Although, to make things easier Access can handle all this using the following:
2 extra fields were added as examples of inserting different data types.
sql.jpg
Bookmarks