Run-time error '13': Type mismatch Me.Count

Hi, There was a question asked by dkropacsy back on 1/15/2004.  It was answered by flavo.  

I found this answer when searching for questions re: MsgBox Err.Description  as I cannot seem to be able to change the coding in my form to allow me to modify the error message the user gets when they keep hitting the "Previous" command button I created using the command button wizard.

When reading the answer I found capricorn1 had responded and I would like to use his answer.  However, the code will not work and I believe it is because VB has changed in the past 2 3/4 years since he originally answered the question.  

When opening the form I get the error code I put in the title of this question.   Here is the code as I have modified it:
_________________________________________________________________________________
Private Sub Form_Load()
     
    Set rs = Me.RecordsetClone
    rs.MoveLast
    ' shows current record/total record count
    Me.Count = Me.CurrentRecord & "/" & rs.RecordCount  
    'On the previous line I changed capricorn1's  Me.txtRecCount to Me.Count.  This is what is highlighted when the debug window opens.
    rs.MoveFirst
    PreviousTeamMember.Enabled = False
    If rs.RecordCount > 1 Then
        NextTeamMember.Enabled = True
        Else
        NextTeamMember.Enabled = False
    End If
       
End Sub
_________________________________________________________________________________
Private Sub PreviousTeamMember_Click()
On Error GoTo Err_PreviousTeamMember_Click

    DoCmd.GoToRecord , , acPrevious
 
   Me.Count = Me.CurrentRecord & "/" & rs.RecordCount
    If Me.CurrentRecord = 1 And rs.RecordCount > 1 Then
        NextTeamMember.Enabled = True
        NextTeamMember.SetFocus
        PreviousTeamMember.Enabled = False
    End If
    If Me.CurrentRecord < rs.RecordCount Then
        NextTeamMember.Enabled = True
    End If

Exit_PreviousTeamMember_Click:
    Exit Sub

Err_PreviousTeamMember_Click:

    MsgBox Err.Description
         
    Resume Exit_PreviousTeamMember_Click
   
End Sub
_____________________________________________________________________________

What I was trying to do was change the error message dialog box that pops up when using the Previous command button (PreviousTeamMember).  Instead of it saying "Microsoft Office Access" in the dialog box title bar I want it to say "Whatever Database".  Instead of it saying "You can't go to the specifed record." in the dialog box (the prompt) I want it to say "You are at the first record.  There is no previous record to go to."

Also, when clicking on the Next command button (NextTeamMember), the form goes blank and then the same dialog box pops up again when the user clicks the Next command button again.  I want to change the error message as above, changing the word "Previous" to "Next".  

It would be great if a blank form did not appear when the user clicked on the "Next" button when the last Team Member has been reached.  Is there a way to prevent the form from going blank and having the error message pop up instead of going blank, and still having the Last Team member data loaded on the form?

amkazenAsked:
Who is Participating?
 
Rey Obrero (Capricorn1)Connect With a Mentor Commented:
try revising this

Exit_PreviousTeamMember_Click:
    Exit Sub

Err_PreviousTeamMember_Click:

    'MsgBox Err.Description
       MsgBox "helloo............................................."  
    Resume Exit_PreviousTeamMember_Click
0
 
Rey Obrero (Capricorn1)Commented:

Me.txtRecCount  ' refers to a textbox in the form

ME.Count is a property of the form.

create a textbox and name it  txtRecCount
0
 
amkazenAuthor Commented:
LOL!  That worked.  Such a simple thing.  Shows how much I still do not know...a TON.  LOL

What about changing the error message?  Something simple there also? We can deal with the blank form after changing the error message, right?
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

 
amkazenAuthor Commented:
I changed the error message as you said and it worked.  I then tried the following and it worked.
               MsgBox "helloo.............................................", , "My Title"
I was able to change the title.

Small problem, however:  "Our" above error message only appears after clicking "OK" on the original Access error message as it still appears, and appears before "our" error message.

Additionally, should the  txtRecCount  text box change as the records are scrolled through?  It only reads   1/5   as I only have 5 records of test data.


And now this.  Now when I click the NextTeamMember or PreviousTeamMember buttons I get a dialog error box saying "Object Required".  Also, I think I probably should have my command buttons named differently from my functions.  I had not realized I had done that until just now.  Maybe that is causing the problem, and if it is not it cannot be good programming.  I can remove the code below that I added (the if statements) and the Object Required dialog box goes away. Here is the code, and I am going home.  I need a break.
_____________________________________________________________
Private Sub Form_Load()
    Set rs = Me.RecordsetClone
    rs.MoveLast
    Me.txtRecCount = Me.CurrentRecord & "/" & rs.RecordCount ' shows current record/total record count
    rs.MoveFirst
    PreviousTeamMember.Enabled = False
    If rs.RecordCount > 1 Then
        NextTeamMember.Enabled = True
        Else
        NextTeamMember.Enabled = False
    End If
       
End Sub
______________________________________________________________

Private Sub NextTeamMember_Click()
On Error GoTo Err_NextTeamMember_Click

    DoCmd.GoToRecord , , acNext
    Me.txtRecCount = Me.CurrentRecord & "/" & rs.RecordCount
    If Me.CurrentRecord < rs.RecordCount Or Me.CurrentRecord > 1 Then
        PreviousTeamMember.Enabled = True
    End If
   
    If Me.CurrentRecord = rs.RecordCount Then
        PreviousTeamMember.SetFocus
        NextTeamMember.Enabled = False
    End If

Exit_NextTeamMember_Click:
    Exit Sub

Err_NextTeamMember_Click:
    MsgBox Err.Description
    MsgBox "helloo next............................", , "My Title"

    Resume Exit_NextTeamMember_Click
   
End Sub
_______________________________________________________________

Private Sub PreviousTeamMember_Click()
On Error GoTo Err_PreviousTeamMember_Click

    DoCmd.GoToRecord , , acPrevious
 
 Me.txtRecCount = Me.CurrentRecord & "/" & rs.RecordCount
    If Me.CurrentRecord = 1 And rs.RecordCount > 1 Then
        NextTeamMember.Enabled = True
        NextTeamMember.SetFocus
        PreviousTeamMember.Enabled = False
    End If
    If Me.CurrentRecord < rs.RecordCount Then
        NextTeamMember.Enabled = True
    End If
 
 Exit_PreviousTeamMember_Click:
    Exit Sub

Err_PreviousTeamMember_Click:

    MsgBox Err.Description
    MsgBox "helloo  previous.......................", , "My Title"
    Resume Exit_PreviousTeamMember_Click
   
End Sub





0
 
Rey Obrero (Capricorn1)Commented:

   ' MsgBox Err.Description       <<<< i commented this line , do not include this line

    MsgBox "helloo  previous.......................", , "My Title"
    Resume Exit_PreviousTeamMember_Click
0
 
amkazenAuthor Commented:
Thanks, capricorn1!
0
 
Rey Obrero (Capricorn1)Commented:
U R Welcome!!!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.