J
jim_s via AccessMonster.com
Hi all,
I must have scoured this forum for a day looking for some alternative answer
to this question, and googling the issue doesn't seem to help me much either.
I have two tables, 'Search Result' and 'For Export'. When a user wants to
amend a record in the Search Result form/table, the form's text boxes all
unlock for editing. Once this is done, the user has two options - Save
Changes or Cancel. I think you'll have caught on by this stage that the
'Cancel' button works.
When 'Save Changes' is hit, the button needs to append the current record to
a new table, 'For Export'
The closest I've come is through some VB code posted on the forums:
Const myTarget As String = "For Export"
Const myPrimaryKey = "RTL_DAS_Ref"
Dim pk As Variant
Dim strSQL As String
Dim rs As DAO.Recordset
Set rs = Me.RecordsetClone
pk = rs(RTL_DAS_Ref).Value
strSQL = "INSERT INTO " & myTarget & " SELECT * FROM " & rs.Name & " WHERE "
& myPrimaryKey & "=" & pk
Set rs = Nothing
CurrentDb.Execute (strSQL), dbFailOnError
Whilst it all seems logical to get the SQL code to match the recordsetclone
PK to the current record PK, I'm getting a syntax error in the SQL statement
for the INSERT INTO command. It looks okay to me! Any pointers? Please don't
tell me it's something blazingly obvious that I've not spotted!
I must have scoured this forum for a day looking for some alternative answer
to this question, and googling the issue doesn't seem to help me much either.
I have two tables, 'Search Result' and 'For Export'. When a user wants to
amend a record in the Search Result form/table, the form's text boxes all
unlock for editing. Once this is done, the user has two options - Save
Changes or Cancel. I think you'll have caught on by this stage that the
'Cancel' button works.
When 'Save Changes' is hit, the button needs to append the current record to
a new table, 'For Export'
The closest I've come is through some VB code posted on the forums:
Const myTarget As String = "For Export"
Const myPrimaryKey = "RTL_DAS_Ref"
Dim pk As Variant
Dim strSQL As String
Dim rs As DAO.Recordset
Set rs = Me.RecordsetClone
pk = rs(RTL_DAS_Ref).Value
strSQL = "INSERT INTO " & myTarget & " SELECT * FROM " & rs.Name & " WHERE "
& myPrimaryKey & "=" & pk
Set rs = Nothing
CurrentDb.Execute (strSQL), dbFailOnError
Whilst it all seems logical to get the SQL code to match the recordsetclone
PK to the current record PK, I'm getting a syntax error in the SQL statement
for the INSERT INTO command. It looks okay to me! Any pointers? Please don't
tell me it's something blazingly obvious that I've not spotted!