Access 2000: Selecting records programmatically

  • Thread starter Thread starter Mike Mertes
  • Start date Start date
M

Mike Mertes

Hi all! :)

What objects and methods are used to manipulate the record selectors on a
form? For instance, how do I switch to the last record? Or switch to a new
record?

Also, what steps should I take to run code when the an *.mdb closes? I've
noticed that there are no Auto_Open/Auto_Close events. I am aware of the
AutoExec macro, does it have an opposite?

Thanks for helping us Access newbies :)

-Mike Mertes
Airtron, Tamp Bay
 
Use the RecordsetClone to find and move to records in the form.

Example: move to last record:
With Me.RecordsetClone
.MoveLast
Me.Boomkark = .Bookmark
End With

Example: move to a particular record:
With Me.RecordsetClone
.FindFirst "ClientID = 99"
If .NoMatch Then
Msgbox "Not found"
Else
Me.Bookmark = .Bookmark
End If
End With

To move to a new record, the form must have focus:
If Not Me.NewRecord Then
RunCommand acCmdRecordsGotoNew
End If

In each of those cases, the current record must be saved before the move can
happen, and you can avoid some problems if you do that explicitly:
If Me.Dirty Then
Me.Dirty = False
End If

To simulate an application close event, open a hidden form, and use its
Unload event.
 
Back
Top