Append a Single Record

A

Andy Josolyne

I would like to use an append query to append records from a table using a
button on a form. How do I modify the append query to only append the form
record and do I insert the expression in the query criteria field? Grateful
for your advice.
 
M

Michel Walsh

Hi,



DoCmd.RunSQL "INSERT INTO tableName(field1, field2, field3)
VALUES(FORMS!FormName!Control1,
FORMS!FormName!Control2,FORMS!FormName!Control3)"




the list of field after the tablename must match the list of values, after
the keyword VALUES. Using DoCmd, you can use the syntax
FORMS!FormName!ControlName, without having to worry about delimiters.


Hoping it may help,
Vanderghast, Access MVP
 
A

Andy Josolyne

Michel

Many thanks for your advice - grateful if you could advise if the code is
inserted into the append query or the build event of the 'run append query
button.
 
M

Michel Walsh

Hi,


The code has to be inserted in a VBA environment, since it uses DoCmd, so I
would use it inside an event handler subroutine, such as under a button
click.


Hoping it may help,
Vanderghast, Access MVP
 
M

Michel Walsh

Hi,


The code has to be inserted in a VBA environment, since it uses DoCmd, so I
would use it inside an event handler subroutine, such as under a button
click.


Hoping it may help,
Vanderghast, Access MVP
 
Top