E
EagleOne
2003
I want to copy one record of TableA which meets conditionX to TableB
PLAN A
Originally I thought that the following VBA code would work:
....
....
Set rs = dBs.OpenRecordset("StarsRev", dbOpenDynaset)
....
Do Until ABSAmt <> Abs(rs!Amt) Or rs.EOF
If ActualAmt + rs!Amt = 0 And (DovNmbr = rs!Dov_NUMBER Or DocNmbr = rs!Doc_NUMBER) Then
With appAccess.DoCmd
.RunCommand acCmdSelectRecord
.RunSQL "INSERT INTO STARSOffsets * SELECT * FROM STARSRev"
End With
End if
Loop
Unfortunately the code failed with the error: "SelectRecord is not available here"
PLAN B
When PLAN A failed, I altered the VBA code above to:
Do Until ABSAmt <> Abs(rs!Amt) Or rs.EOF
If ActualAmt + rs!Amt = 0 And (DovNmbr = rs!Dov_NUMBER Or DocNmbr = rs!Doc_NUMBER) Then
dBs.Execute "INSERT INTO STARSOffsets SELECT * FROM STARSRev"
End if
Loop
As I expected, all records in STARSRev are copied in to STARSOffsets using the VBA code in PLAN B
What VBA code can I use to limit the copy to the ONE record meeting the IF condition?
Any thoughts appreciated!
EagleOne
I want to copy one record of TableA which meets conditionX to TableB
PLAN A
Originally I thought that the following VBA code would work:
....
....
Set rs = dBs.OpenRecordset("StarsRev", dbOpenDynaset)
....
Do Until ABSAmt <> Abs(rs!Amt) Or rs.EOF
If ActualAmt + rs!Amt = 0 And (DovNmbr = rs!Dov_NUMBER Or DocNmbr = rs!Doc_NUMBER) Then
With appAccess.DoCmd
.RunCommand acCmdSelectRecord
.RunSQL "INSERT INTO STARSOffsets * SELECT * FROM STARSRev"
End With
End if
Loop
Unfortunately the code failed with the error: "SelectRecord is not available here"
PLAN B
When PLAN A failed, I altered the VBA code above to:
Do Until ABSAmt <> Abs(rs!Amt) Or rs.EOF
If ActualAmt + rs!Amt = 0 And (DovNmbr = rs!Dov_NUMBER Or DocNmbr = rs!Doc_NUMBER) Then
dBs.Execute "INSERT INTO STARSOffsets SELECT * FROM STARSRev"
End if
Loop
As I expected, all records in STARSRev are copied in to STARSOffsets using the VBA code in PLAN B
What VBA code can I use to limit the copy to the ONE record meeting the IF condition?
Any thoughts appreciated!
EagleOne