Moving a record in a form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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
 
Back
Top