
Type Mismatch Run-Time error 13
I am a new
VBA coder trying to set up the simple
enabling/disabling of navigational buttons depending on
the positon of the displayed record in the recordset.
This code is tied to a form with a single table query for
the Record Source. I keep getting a type mismatch error
when the following code runs. I have declared the object
variable Private RS as Recordset in the general
declarations area. Here is the code [EnableNavButtons
()]. Any ideas why this keeps happening? This procedure
is called from several other subs (first, last, next, ...)
tied to command buttons. (Current Rec is also declared as
a String in the general declaration area).
Private Sub cmdFirst_Click()
DoCmd.GoToRecord , , acFirst
CurrentRec = Bookmark
WorkstationID.SetFocus
EnableNavButtons
End Sub
Public Sub EnableNavButtons()
'declare the FirstRec and LastRec string variables
Dim FirstRec As String
Dim LastRec As String
'code to assign the FirstRec and LastRec variables
Set RS = Forms!frmAssets.RecordsetClone
RS.MoveLast
LastRec = RS.Bookmark
RS.MoveFirst
FirstRec = RS.Bookmark
'code to enable/disable command buttons depending on
where you are in the recordset
Select Case CurrentRec
Case FirstRec
cmdFirst.Enabled = False
cmdPrevious.Enabled = False
cmdNext.Enabled = True
cmdLast.Enabled = True
cmdNewRecord.Enabled = True
Case LastRec
cmdFirst.Enabled = True
cmdPrevious.Enabled = True
cmdNext.Enabled = False
cmdLast.Enabled = False
cmdNewRecord.Enabled = True
Case Else
cmdFirst.Enabled = True
cmdPrevious.Enabled = True
cmdNext.Enabled = True
cmdLast.Enabled = True
cmdNewRecord.Enabled = True
End Select
End Sub
The error occurs here:
Set RS = Forms!frmAssets.RecordsetClone
I have even tried using Me.RecordsetClone and still the
same outcome. Any help would be appreciated.
Thanks, Van