Check for record loaded on form

  • Thread starter Thread starter Lance
  • Start date Start date
L

Lance

Hello,

What is the command to check if a record is loaded within a form in
VBA?

Looking to check when the form changes, so that I can enable or disable
pieces of the form that shouldn't be used when there is no record
loaded.

Also, if anyone could point me to a handy online resource that is able
to cover simple questions such as these so I don't have to ask them,
that'd be great too, save us all time :p

Thanks,

Lance
 
The form's Current event fires whenever you go from one record to another,
even as you go to the first record when the form opens. If there are
records, then one will be loaded. To see if there are any records, you could
check the form's recordset's RecordCount property. Also, you may want to
make sure that you're not at a new record. The record count will get
adjusted if you filter the form. The Current event will also fire when the
form is filtered or unfiltered.

Example:
If Me.Recordset.RecordCount > 0 And Me.NewRecord = False Then
'Place your desired action here
End If

Instead of getting a record count, you could also use the If statement to
check the value of certain fields then make adjustments if that is what you
want.

There are several web sites that have information on Access. One you may
want to start with is http://www.mvps.org/access.
 
Back
Top