Workingonit
Registered User.
- Local time
- Yesterday, 23:10
- Joined
- Jun 4, 2015
- Messages
- 10
I have a form that has a subform on it. The main form shows a category of furniture and has custom navigation buttons and a search text box for asset numbers and command button that runs the search. The subform shows the asset numbers associated with that furniture category, sometimes there is only one asset number, in other cases there could be 60. There is a scroll bar to scroll through the asset numbers when there are too many to see in the initial window.
The buttons all work as they should except when I search for an asset number that is part of a category that has too many asset numbers to show in the main window. When this happens the "previous" and "next" navigation buttons do not take you to the previous or next record. All of the other buttons on the form work though - you can go to the first, or the last record, and you can search for a new asset.
This is the code for the search:
This is the code for the previous and next buttons:
I've also attached a picture of what I mean when I say there are more asset numbers than what the window shows.
Any insight at all as to what might be happening would be supremely appreciated! Thank you!
The buttons all work as they should except when I search for an asset number that is part of a category that has too many asset numbers to show in the main window. When this happens the "previous" and "next" navigation buttons do not take you to the previous or next record. All of the other buttons on the form work though - you can go to the first, or the last record, and you can search for a new asset.
This is the code for the search:
Code:
Private Sub cmdAssetSearch_Click()
Dim rs As Object
If IsNull(Me.TextAsset) Or Me.TextAsset = "" Then
MsgBox "Please type in an asset number to search for.", vbOKOnly
Me.TextAsset.SetFocus
Else
If DCount("[Asset Number]", "[Qry_FurnitureCodeAsset]", "[Asset Number]=" & Me.TextAsset) = 0 Then
MsgBox "Please check the asset number entered and search again.", vbOKOnly
Else
Set rs = Me.Recordset.Clone 'this is the main form
rs.FindFirst "[Asset Number] = " & Me.TextAsset.Value
Me.Bookmark = rs.Bookmark
rs.Close
Set rs = Nothing
End If
End If
Me.TextAsset = ""
Forms!Furniture_CategoryCodeAsset![Item Code].SetFocus
End Sub
Code:
Private Sub cmdPrevious_Click()
On Error GoTo OnNextRecord
DoCmd.RunCommand acCmdRecordsGoToPrevious
GoTo wayout
OnNextRecord:
MsgBox "You're already on the first record."
wayout:
On Error GoTo 0
End Sub
Private Sub cmdNext_Click()
On Error GoTo OnNextRecord
DoCmd.RunCommand acCmdRecordsGoToNext
GoTo wayout
OnNextRecord:
MsgBox "You're already on the last record."
wayout:
On Error GoTo 0
End Sub
Any insight at all as to what might be happening would be supremely appreciated! Thank you!