When FindFirst is Null... How to test and skip the following code

  • Thread starter Thread starter Kahuna
  • Start date Start date
K

Kahuna

I have the following code that has worked well in the past - though I've
obviously not used it where a record to be archived had null value (or more
correctly, the record did not exist).

Here's the scenario.

Main Table FabCon PK is fc_id
Related Table Remarks FK is fc_fabric_key

The code is used to find a Remarks record that relates to the current FabCon
record.

This works fine until the line 'rstFabRemark.FindFirst FindCriteria2' -
which when it encounters a FabCon record with no matching Remarks record is
simply ignored and the following code ' .[fc_rem_cd_1] =
rstFabRemark![remark_code]' simply holds on to the last [remark_code] it was
set with.

My question is:

1. Can I test for an empty FindCriteria2 and then skip the archive code
completely?.


'*************************** inset the Remark Archive Code Here
'Find First Rem Code for
this FabCon record
varRecID = rstFabCon![fc_id]
'set to current FabCon Record Number
'MsgBox varRecID
On Error Resume Next
' MsgBox
rstFabRemark![fc_fabric_key]
varRemKey =
rstFabRemark![fc_fabric_key]
'Where Remarks Fabric
Key is same as FabCon Record Number"
FindCriteria2 =
"[inspection_remarks]![fc_fabric_key] = " & varRecID
' MsgBox FindCriteria2
'***First Remark

rstFabRemark.FindFirst
FindCriteria2
' MsgBox
rstFabRemark![fc_fabric_key]
'Add the RemCd to
rstFabArchive
.[fc_rem_cd_1] =
rstFabRemark![remark_code]
varRemCode =
rstFabRemark![remark_code]

Any different suggestion welcome.

TIA
 
I'm now convinced that the very act of placing a question on this forum
causes my brain to do a sideways leap.

Of course its a '.NoMatch'

Thanks for reading this though.

Cheers
 
Back
Top