Type Mismatch Run-Time error 13 
Author Message
 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



Sun, 11 Sep 2005 06:19:26 GMT  
 Type Mismatch Run-Time error 13
Try:
    Private RS As DAO.Recordset

The ADO library also has a Recordset object.

More info:
    http://users.bigpond.net.au/abrowne1/ser-38.html

--
Allen Browne - Microsoft MVP.  Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to the newsgroup. (Email address has spurious "_SpamTrap")


Quote:
> 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



Sun, 11 Sep 2005 15:42:04 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Type mismatch, run-time error #13

2. Mdac2.6 to Mdac2.7 causes Type Mismatch Runtime Error 13

3. ACC2000:Run Time Error '13': Type Mismatch

4. Run -time error '13' Type Mismatch

5. Run-time error '13': Type mismatch

6. Run-time error '13': Type mismatch

7. Run-time error '13': Type mismatch

8. Run Time Error 13 Type Mismatch

9. run time error 13, data type mismatch !

10. "Run-time error 13: Type Mismatch"

11. Run Time Error "13" Type Mismatch

12. Type Mismatch - Run Time Err 13

 

 
Powered by phpBB® Forum Software