Solved

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

Posted on 2006-10-26
7
233 Views
Last Modified: 2012-08-13
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?

0
Comment
Question by:amkazen
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 17815745

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
 

Author Comment

by:amkazen
ID: 17815777
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
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 250 total points
ID: 17815801
try revising this

Exit_PreviousTeamMember_Click:
    Exit Sub

Err_PreviousTeamMember_Click:

    'MsgBox Err.Description
       MsgBox "helloo............................................."  
    Resume Exit_PreviousTeamMember_Click
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:amkazen
ID: 17815979
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
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 17815993

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

    MsgBox "helloo  previous.......................", , "My Title"
    Resume Exit_PreviousTeamMember_Click
0
 

Author Comment

by:amkazen
ID: 17844182
Thanks, capricorn1!
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 17844204
U R Welcome!!!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

632 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question