Copy Record

  • Thread starter Thread starter Jaosn Frazer
  • Start date Start date
J

Jaosn Frazer

I have a form named [MSDS_Form] that references a query
named [MSDS_Query]. The query combines data from 2
tables. [Product] and [MSDS].
I want to copy the current record in the form to the next
autonumber. How can I copy the record in the table
[Product] and [MSDS] to the next autonumber?
 
Hi,



CurrentDb.Execute "INSERT INTO myTable (listOfFields) VALUES
(listOfValues) ; "


would append a new record in the specified table. If you use DoCmd.RunSQL,
you can use the syntax FORMS!FormName!ControlName, without delimiter:

DoCmd.RunSQL "INSERT INTO myTable( firstName) VALUES (
FORMS!MyFormName!FirstName ) ; "


otherwise, you need to "im-print" the value:

Dim str As String
str = "INSERT INTO myTable( firstName) VALUES( """ &
FORMS!MyFormName!FirstName & """) ; "

' Debug.Print str ' to print in the debug the statement to be
executed...
CurrentDb.Execute str



Hoping it may help,
Vanderghast, Access MVP
 
Back
Top