Hello folks!
So, I've been doing some Access stuff in VBA. I managed to add "previous record" and "next record" buttons to a form that would display different info depending on the the record.
The problem is, my "Next Record" button doesn't work at all. When I load the form and click "Next", nothing happens. It doesn't refresh the form or do anything.
However, when I click on the "Previous Record" button, it works perfectly fine. Then, if I try to click on the Next button again, it works.
Basically, when the form loads, unless I first go to the previous record (the form loads the 1st record by default), I can't go to the next one. This is my code:
Any idea what the issue could be? It worked perfectly fine until today. I may have messed up, but I genuinely have no idea what the issue is.
So, I've been doing some Access stuff in VBA. I managed to add "previous record" and "next record" buttons to a form that would display different info depending on the the record.
The problem is, my "Next Record" button doesn't work at all. When I load the form and click "Next", nothing happens. It doesn't refresh the form or do anything.
However, when I click on the "Previous Record" button, it works perfectly fine. Then, if I try to click on the Next button again, it works.
Basically, when the form loads, unless I first go to the previous record (the form loads the 1st record by default), I can't go to the next one. This is my code:
Code:
Private Sub btn_Next_Click()
'MsgBox Me.CurrentRecord
'MsgBox Me.Recordset.RecordCount
If Me.CurrentRecord < Me.Recordset.RecordCount Then
DoCmd.GoToRecord , , acNext
Else
DoCmd.GoToRecord , , acFirst
End If
Me.imgBanner.Picture = GetImagePath() & "Banners/" & Me.txt_Banner.Value
Me.lbl_GameName.Caption = Me.GameName.Value
Me.lbl_ReleaseDate.Caption = "Release date: " & Me.ReleaseDate.Value
Me.lbl_MaxSlot.Caption = "Max Slots: " & Me.MaxSlot.Value
If IsNull(Me.OfficialWebsite.Value) Or Me.OfficialWebsite.Value = "" Then
Me.lbl_Website.Caption = "Website: " & "N/A"
Else
Me.lbl_Website.Caption = "Website: " & vbNewLine & Me.OfficialWebsite.Value
End If
End Sub
Private Sub btn_Previous_Click()
If Me.CurrentRecord = 1 Then
DoCmd.GoToRecord , , acLast
Else
DoCmd.GoToRecord , , acPrevious
End If
Me.imgBanner.Picture = GetImagePath() & "Banners/" & Me.txt_Banner.Value
Me.lbl_GameName.Caption = Me.GameName.Value
Me.lbl_ReleaseDate.Caption = "Release date: " & Me.ReleaseDate.Value
Me.lbl_MaxSlot.Caption = "Max Slots: " & Me.MaxSlot.Value
If IsNull(Me.OfficialWebsite.Value) Or Me.OfficialWebsite.Value = "" Then
Me.lbl_Website.Caption = "Website: " & "N/A"
Else
Me.lbl_Website.Caption = "Website: " & vbNewLine & Me.OfficialWebsite.Value
End If
End Sub
Any idea what the issue could be? It worked perfectly fine until today. I may have messed up, but I genuinely have no idea what the issue is.
Last edited: