Current Event & non-existant records

  • Thread starter Thread starter Marc Hillman
  • Start date Start date
M

Marc Hillman

I have a conventional form with a subform. Form records are linked to
subform records via a link master field. Move to a different record on the
form, and the subform records change to synchronise with the current form
record.

A problem occurs when there are no records to display on the subform (ie no
child records). In the Current event method for the subform I set a few
buttons based on values in the current record. When there is no current
record, I get an error (2424) which is to be expected I guess, but why is
the current event called, and how do I skip it when there is no real current
record?

I've put "if Me.RecordsetClone.RecordCount > 0 then ... end if" around the
event handler to 'fix' the problem, but this is a bit of a kludge.

How do I robustly check that I actually have a real current record in the
current event, and not one of the other reasons that Current may be called?

TIA
_______________________________________
Marc Hillman, Melbourne, Australia
web: http://users.tpg.com.au/mhillman/
 
Marc said:
I have a conventional form with a subform. Form records are linked to
subform records via a link master field. Move to a different record on the
form, and the subform records change to synchronise with the current form
record.

A problem occurs when there are no records to display on the subform (ie no
child records). In the Current event method for the subform I set a few
buttons based on values in the current record. When there is no current
record, I get an error (2424) which is to be expected I guess, but why is
the current event called, and how do I skip it when there is no real current
record?

I've put "if Me.RecordsetClone.RecordCount > 0 then ... end if" around the
event handler to 'fix' the problem, but this is a bit of a kludge.

How do I robustly check that I actually have a real current record in the
current event, and not one of the other reasons that Current may be called?

What you have is OK, but another way would be:

If Not Me.NewRecord Then
 
Wouldn't Me.NewRecord be false if there was no record at all?

There is no record because allowadditions, allowdeletions and allowedits are
all false.
 
Marc said:
Wouldn't Me.NewRecord be false if there was no record at all?

There is no record because allowadditions, allowdeletions and allowedits are
all false.

Ahh Yes, under those conditions, you're right.
 
Back
Top