Moving a record in a form

D

David

Hello,
In the form I would like to move some of the feilds in the current record to
another table as a new record. I would like to achieve this by using a
command button , but I'm not sure how to even start the coding for this.

I know my question goes against basic db design concepts, but I think it
will serve as a quick fix until the db is rebuilt.

I hope someone can help me with this.
David
 
J

John Nurick

Hi David,

I'd do this by writing VBA code to build and execute a SQL single-record
append query. The syntax for these is

INSERT INTO target
[(field1[, field2[, ...]])]
VALUES (value1[, value2[, ...])
;

and the code - which goes in the commandbutton's Click event procedure -
would look something like this:

Dim strSQL As String

strSQL = "INSERT INTO TheOtherTable " _
& "(ANumberField, ATextField, ADateField) VALUES (" _
& Me.ANumberField & ", " _
& """" & Me.ATextField & """, " _
& Me.ADateField & ");"

DBEngine(0)(0).Execute strSQL, dbFailOnError
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top