Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2006-10-26
7
Medium Priority
?
234 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 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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 

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

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!

Question has a verified solution.

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

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
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…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

715 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