Public Sub updateButtons(Optional bLockEm As Variant)
'-----------------------------------------------------
'-The position of the 0 or 1 in the string represents
'-a specific button in our cmdButton control array.
'-----------------------------------------------------
'-Position Button
'- 0 move first
'- 1 move previous
'- 2 move next
'- 3 move last
'- 4 add a new record
'- 5 edit the current record
'- 6 save the current record
'- 7 delete the current record
'- 8 undo any current changes
'- 9 find a specific record
'- 10 scan a file
'- 11 open a saved file
'- 12 done. Unload the form
'-----------------------------------------------------
Select Case Data1.Recordset.EditMode
Case dbEditNone '-no editing taking place, just handle navigation
If (lTotalRecords >= 2) Then
If (Data1.Recordset.BOF) Or (Data1.Recordset.AbsolutePosition = 0) Then
navigateButtons ("0011110101011")
ElseIf (Data1.Recordset.EOF) Or (Data1.Recordset.AbsolutePosition = lTotalRecords - 1) Then
navigateButtons ("1100110101011")
Else
navigateButtons ("1111110101011")
End If
ElseIf (lTotalRecords > 0) Then
navigateButtons ("0000110100111")
Else
navigateButtons ("0000100000001")
End If
If (Not IsMissing(bLockEm)) Then
lockTheControls (bLockEm)
End If
Case dbEditInProgress '-we are editing a current record
Call lockTheControls(False)
navigateButtons ("0000001010100")
If (Text1(0).Visible) Then Text1(0).SetFocus
Case dbEditAdd '-we are adding a new record
Call lockTheControls(False)
navigateButtons ("0000001010100")
If (Text1(0).Visible) Then Text1(0).SetFocus
End Select
End Sub
Public Sub navigateButtons(sButtonString As String)
'--------------------------------------------------
'-This routine handles setting the enabled
'-property to true/false on the buttons
'--------------------------------------------------
'-A string of 0101 passed. If 0, disabled
'--------------------------------------------------
Dim iIndx As Integer
Dim iButtonLength As Integer
sButtonString = Trim$(sButtonString)
iButtonLength = Len(sButtonString)
For iIndx = 1 To iButtonLength
If (Mid$(sButtonString, iIndx, 1) = "1") Then
Command1(iIndx - 1).Enabled = True
Else
Command1(iIndx - 1).Enabled = False
End If
Next
DoEvents
End Sub