vba - Insert data from a form into a table -
this question exact duplicate of:
- inserting data form table 1 answer
it's been 3 years since have had use vb or vba code. working on project work using microsoft access need take information listed on form , insert table. stuck on last part of code values part. have far.
insert volunteers (name, email, number, emergency contact, emergency number) values (and stuck)
thank in advance!
you want single-record table append query:
insert volunteers (name, email, number, emergency contact, emergency number) values ("value1", "value2", "value3", "value4", "value5")
assuming constructing sql statement in code-behind of form, can access controls name:
dim sql string sql = _ "insert volunteers (name, email, number, emergency contact, emergency number) " & _ "values (""" & txbname & """, """ & txbemail & """, """ & txbnumber & """, """ & txbemergencycontact & """, """ & txbemergencynumber & ")"
(all triple-quotes double-quote ("
) final sql statement, text fields; numeric fields don't need delimiter, , date fields use #
delimiter.)
if adding values different form, can access them so:
forms!otherform!controlname
and values in subform (iirc):
subformcontrol.form!controlname
see here more details.
Comments
Post a Comment