Page 1 of 2 12 LastLast
Results 1 to 15 of 19
  1. #1
    Join Date
    Feb 2009
    Posts
    49

    Unanswered: type mismatch runtime error 13 access 2007

    hi

    I just migrated to ms access 2007 and created my own ribbon.
    In my form, I have this "print" button where if you click that it will open the "report form"

    here is what I wrote in my VBA code:

    Case "btnPrintRevisionEingabe"
    DoCmd.OpenReport acReport, "Revision_Eingabe_rpt", acSaveNo

    and when I clicked on the "print" button

    I'm getting an error "type mismatch runtime error 13"....

    Please help..
    Thanks

  2. #2
    Join Date
    Feb 2009
    Posts
    49

    type mismatch runtime error 13 access 2007

    hi

    I just migrated to ms access 2007 and created my own ribbon.
    In my form, I have this "print" button where if you click that it will open the "report form"

    here is what I wrote in my VBA code:

    Case "btnPrintRevisionEingabe"
    DoCmd.OpenReport acReport, "Revision_Eingabe_rpt", acSaveNo

    and when I clicked on the "print" button

    I'm getting an error "type mismatch runtime error 13"....

    Please help..
    Thanks

  3. #3
    Join Date
    Jul 2003
    Location
    Michigan
    Posts
    1,941
    Which of those 2 lines is the error happening on?

    My guess would be the Case ... line

    What is your initial Select Case statement?
    Inspiration Through Fermentation

  4. #4
    Join Date
    Feb 2009
    Posts
    49
    I guess I solved it.
    here is what I did:

    DoCmd.OpenReport "Revision_Eingabe_rpt", acViewReport

    and I'm not getting any error anymore.
    Thanks

  5. #5
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    It's not the error I would have expected, but the acSaveNo is an inappropriate argument. Try dropping that (and the comma).
    Paul

  6. #6
    Join Date
    May 2011
    Posts
    11

    Type mismatch error 13 inputbox

    Hi, I have a problem. I am still a baby when it comes to VBA. I have this problem. In my input box when I click cancel it shows an error message "Type Mismatch error 13" What does it mean? I have attached a macro "Duplicate" to the above. No problem. When the user inputs a number x into the input box, it runs the duplicate macro x times. If the user clicks OK there is also no problem since the default value is 0. Its only when the user clicks cancel. Any help please?

  7. #7
    Join Date
    May 2011
    Posts
    11
    The function looks like this.

    Private Sub Command20_Click()
    Dim intHowMany As Integer
    Dim intCounter As Integer


    intHowMany = InputBox(Prompt, "How Many", 0)
    For intCounter = 1 To intHowMany
    DoCmd****nMacro "Duplicate"
    Next intCounter
    End Sub

    OK its RunMacro with a dot in front
    Last edited by Abu Haniffa; 05-11-11 at 02:57. Reason: wrong spelling of function

  8. #8
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    If memory serves, clicking cancel on an InputBox returns a zero length string (""). An Integer variable can't handle a ZLS, hence the mismatch error. Try using Variant.
    Paul

  9. #9
    Join Date
    May 2011
    Posts
    11

    Type mismatch error 13 inputbox

    Thank you for your prompt reply, Paul. I have tried using Variant, but there is no change.It also negates the activation of the macro. I am not sure but has it got anything to do with "As string"? Can you give and example of how I could set up Variant and if it is possible the "As String" too? Like I said I know very little about VB! But I am willing to learn. Thank you.

    The function looks like this.

    Private Sub Command20_Click()
    Dim intHowMany As Integer
    Dim intCounter As Integer


    intHowMany = InputBox(Prompt, "How Many", 0)
    For intCounter = 1 To intHowMany
    DoCmd****nMacro "Duplicate"
    Next intCounter
    End Sub

    OK its RunMacro with a dot in front
    Last edited by Abu Haniffa; 05-11-11 at 21:14. Reason: Additional

  10. #10
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    Did you try

    Dim intHowMany As Variant

    Also, you'd have to test intHowMany to make sure it has a number before proceeding with the For/Next loop. I'd probably use IsNumeric().
    Paul

  11. #11
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    Quote Originally Posted by pbaldy View Post
    It's not the error I would have expected...
    His original code
    Quote Originally Posted by tintincute View Post
    DoCmd.OpenReport acReport, "Revision_Eingabe_rpt", acSaveNo
    incorrectly gave the ObjectType (acReport), which returns an Integer, I believe, as the first argument, instead of the form name, which is a String. This caused the 'type mismatch' error. His revised code
    Quote Originally Posted by tintincute View Post
    DoCmd.OpenReport "Revision_Eingabe_rpt", acViewReport...
    correctly gave the form as the first argument.

    Linq ;0)>
    Last edited by Missinglinq; 05-12-11 at 08:33.
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  12. #12
    Join Date
    May 2011
    Posts
    11

    Eureka!

    Quote Originally Posted by pbaldy View Post
    Did you try

    Dim intHowMany As Variant

    Also, you'd have to test intHowMany to make sure it has a number before proceeding with the For/Next loop. I'd probably use IsNumeric().
    Thank You! Using your directions, I got it working with the following. Thank you again, dear Mahaguru!

    Private Sub Command20_Click()
    Dim intHowMany As Variant
    Dim intCounter As Variant

    intHowMany = InputBox("How Many")
    If Not IsNumeric(intHowMany) Then
    MsgBox "This action is cancelled!"
    ElseIf IsNumeric(intHowMany) Then
    For intCounter = 1 To intHowMany
    DoCmd****nMacro "Duplicate"
    Next intCounter
    End If
    End Sub

    (OK its RunMacro with a dot in front...again)
    Last edited by Abu Haniffa; 05-13-11 at 04:09.

  13. #13
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    Happy to help! One minor point, you don't need the ElseIf test. If the value failed the If test then it must be numeric. I'd just have Else there; it avoids the slight performance hit of testing the variable again.

    I think what's happening when you post the RunMacro code is that the forum software sees the dot-r-u portion of it and thinks it might be a Russian spam site. It changes it to ****.
    Paul

  14. #14
    Join Date
    May 2011
    Posts
    11

    Thumbs up

    Sorry for the late reply. I have been busy with my database trying to complete it and learning as much as I can in the process. (Happy to say I am getting the hang of it.) Can I ask you a question? Once my database is finished, what are the steps to take to ensure that everything is working properly? Are there any standard methods?

    With regards to the "dot" enigma, I think sometimes taking the cautious path is better. So what's with a dot here or there? (expect for those who are writing code)

    Thank you again. My greatest challenge was that Input Box.
    Last edited by Abu Haniffa; 05-16-11 at 00:37.

  15. #15
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    In my experience, the best testing is by real users. No matter how much I test myself, users always find different ways of going about things that will find any holes. For a big software company that would be accomplished in beta testing. In a smaller company like the one I work for, I just throw it in and wait for them to break it.
    Paul

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •