Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2006-10-26
7
Medium Priority
?
236 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
  • 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 1000 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Suggested Courses

824 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