Code:
Private Sub cmdEditRepair_Click()
Dim rs As DAO.Recordset
Dim lngBookmark As Long
Dim Record As String '<< not needed
'Dim Cancel As Integer '<< not needed
'test to see if a record is selected
If IsNull(Me.lstEvents) Then
MsgBox "Please select a repair to edit", vbInformation
Exit Sub
End If
'set a variable to the current record
lngBookmark = Me.lstEvents
'open the repair form and close the calendar
DoCmd.OpenForm "frmRepairs"
DoCmd.Close acForm, "frmCalendar"
'take it to the selected record
Set rs = Forms!frmRepairs.RecordsetClone
rs.FindFirst "RepairNumb = " & lngBookmark
Set rs = Nothing
End Sub
The things I added/changed are in blue.
The single line If() function is usually not considered good programing. It was used back when memory was very expensive and bytes were counted.
Here is another way to write your sub:
Code:
Private Sub cmdEditRepair_Click()
'test to see if a record is selected
If IsNull(Me.lstEvents) Then
MsgBox "Please select a repair to edit", vbInformation
Exit Sub
End If
'open the repair form and close the calendar
DoCmd.OpenForm "frmRepairs", , , "RepairNumb = " & Me.lstEvents
DoCmd.Close acForm, "frmCalendar"
End Sub