Cycle to first record?

  • Thread starter Me!Frustrated = True
  • Start date
M

Me!Frustrated = True

I use a form (single form) for Equipment Maintenance that shows both existing
issues and those that have been resolved. I added a simple "Find" button
that should navigate to any records that exist for any recurring problems
with a particular unit. Here is the button code:
Private Sub cmdProblems_Click()
Dim myAsset As Long
myAsset = Me.AssetID
Me.AssetID.SetFocus
DoCmd.FindRecord myAsset, , , , , , False

My problem is, I can only set the options for FindRecord to either start
searching at the first record, or at the one right after the current record.
If a user is looking at the most recent record, I would like the search to
start again at the beginning of the recordset. Is there a way to do what I
want using this method, or do I have to use another method? Or, can a form's
properties be set so that navigating to the "next" record will return to the
first record in the set?

TIA
 
A

Allen Browne

How about applying a filter to the form, so it only shows problems with the
current asset? The user can then click through the records, or jump to the
first or last one, or whatever.

This kind of thing:

Private Sub cmdProblems_Click()
Dim strWhere As String
If Me.Dirty Then Me.Dirty = False 'Save any edits.
If IsNull(Me.AssetID) Then
MsgBox "What asset was that?"
Else
strWhere = "AssetID = " & Me.AssetID
Me.Filter = strWhere
Me.FilterOn = True
End If
End Sub

If AssetID is a Text field (not a Number field), you need extra quotes.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

message
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top