GoTo last record of subform - some blank records

daveblanch

Registered User.
Local time
Today, 17:17
Joined
Aug 3, 2010
Messages
11
Hi,

I've tried searching but haven't come across what i need (might be my poor searching skills)

Basically, i need a subform to default to the latest record.

I have OnCurrent set as [SubFormName].Form.Recordset.MoveLast which works fine when the subform has a record to display.

However some of the main records do not have corresponding records to be displayed in the subform (may have been on annual leave and have no activity in that quarter) and when there is no record an error is thrown.

Could anyone help with the code to check if there is a record before moving to last record and if there is not then to not exectute?

Thanks,
DB.
 
Try this, before your code put the next code.

On Error resume next
 
Of course; its not good practice to have blank records.

One simple way to prevent this is to have at least one field where the Property is Required = Yes where that field is mandatory by your user.
 
mstef's idea is fine. This is useful when you have something that ought to work, but can fail for some known expected reason, and you just want to carry on if it does.

The slight issue is that the resume next may mask a "real" issue.
 

Users who are viewing this thread

Back
Top Bottom