Add new record.

  • Thread starter Thread starter TA
  • Start date Start date
T

TA

Hello & Thanks for reply,
I want to do an error check for a table with 20 columns.
If found an error then put all record information from
Rs_scan into Rs_ErrorScan.
How can I prevent to retype for every single column?
MS Access have function like copy that row and "paste"
that row into another table ?
Like:
If IsNull(Rs_Scan.clientid) Then
Rs_ErrScan.AddNew
Rs_ErrScan!clientid = Rs_Scan.Fields("Clientid")
Rs_ErrScan!errorcode = Rs_Scan.Fields("100"
' ....
' ....
End If
Best Regards,
TA
 
instead of DAO <blech> you should use SQL:

Dim SQL As String

SQL = "INSERT " & _
"INTO Table1 " & _
"SELECT * " & _
"FROM Table2 " & _
"WHERE clientid = NULL;"

CurrentDb.Execute SQL, dbFailOnError

the above will only work if Table1 and Table2 have
matching field structures. if they don't then you have to
do this:

SQL = "INSERT INTO Table1 ( DestField1,
DestField2, ... ) " & _
"SELECT ( SourceField1, SourceField2, ... ) " & _
"FROM Table2 " & _
"WHERE clientid = NULL;"

CurrentDb.Execute SQL, dbFailOnError

hope this helps
note, there is a lot of good information in the help files
too, although its not always enough
 
Thanks Dave,
Best Regards
TA
-----Original Message-----
instead of DAO <blech> you should use SQL:

Dim SQL As String

SQL = "INSERT " & _
"INTO Table1 " & _
"SELECT * " & _
"FROM Table2 " & _
"WHERE clientid = NULL;"

CurrentDb.Execute SQL, dbFailOnError

the above will only work if Table1 and Table2 have
matching field structures. if they don't then you have to
do this:

SQL = "INSERT INTO Table1 ( DestField1,
DestField2, ... ) " & _
"SELECT ( SourceField1, SourceField2, ... ) " & _
"FROM Table2 " & _
"WHERE clientid = NULL;"

CurrentDb.Execute SQL, dbFailOnError

hope this helps
note, there is a lot of good information in the help files
too, although its not always enough


.
 
Back
Top