+ Reply to Thread
Results 1 to 7 of 7

runtime 13 type mismatch

Hybrid View

  1. #1
    Registered User
    Join Date
    02-24-2017
    Location
    Sweden
    MS-Off Ver
    2007
    Posts
    3

    runtime 13 type mismatch

    Why do I get this error??

    I am trying to do

    If LoginFlag = False Then
            Application.Quit
        End If
    also doing

    Global LoginFlag As Boolean
    with a login frame, I want the user not to be able to just close the login frame and start working, I want the user to be forced to login...

    I guess that if the user closes the login frame the LoginFlag is non existant and that is why I get the mismatch, right?

    Anybody got a better solution for force my user to login before start working?
    Last edited by hjortsberg; 02-24-2017 at 05:25 PM.

  2. #2
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,015

    Re: runtime 13 type mismatch

    If you are simply trying to close your app ... just use:

    Application.Quit

  3. #3
    Registered User
    Join Date
    02-24-2017
    Location
    Sweden
    MS-Off Ver
    2007
    Posts
    3

    Re: runtime 13 type mismatch

    Ok, yes, but my problem is that I have a login frame that pops up on opening the workbook, if the user closes the login frame with the cross in the upper right corner he can just start working without entering the right password. So, what I try to do is to put a Application.Quit in various places when the user tries to push some other buttons and won't I need to put the Application.Quit inside an "if" that checks if the login is made or not???

    Or do you have another solution for me?

  4. #4
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,015

    Re: runtime 13 type mismatch

    Here is a complete macro that you can paste into your form's code. It disables the X close method and provides
    instructions to the User how to proceed:

    Private Sub UserForm_QueryClose(Cancel As Integer, _
      CloseMode As Integer)
      If CloseMode = vbFormControlMenu Then
        Cancel = True
        MsgBox "Please use the CLOSE button.", vbExclamation, "Event Error"
      End If
    End Sub
    You can add your own code to the form to close it after the above or direct the user elsewhere.

  5. #5
    Registered User
    Join Date
    02-24-2017
    Location
    Sweden
    MS-Off Ver
    2007
    Posts
    3

    Re: runtime 13 type mismatch

    Works like a charm

    Thanks a ton!

    I started with VBA yesterday and have a long way ahead of me, maybe we will talk again

  6. #6
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,015

    Re: runtime 13 type mismatch

    Use this line of code instead. It disables the X on the form:

    If CloseMode = 0 Then Cancel = True
    That will make them use your method of closing the form or progressing.

  7. #7
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,015

    Re: runtime 13 type mismatch

    Absolutely. I'm still learning ... alot from all kinds of folks here. Been messing with VBA for about 1 year. Lots to learn.

    If this answers your question, please mark the Thread as Solved. Up top, right side. "Thread Tools"

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Type Mismatch Runtime Error 13
    By EXCELBENCH in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 04-21-2015, 05:06 PM
  2. Runtime error'13' - type mismatch
    By Polluz in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-24-2014, 01:12 PM
  3. RunTime Error 13: Type MIsmatch
    By tariq2 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-24-2013, 10:47 AM
  4. [SOLVED] runtime error 13 type mismatch
    By Justair07 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-28-2013, 02:46 PM
  5. runtime error 13 type mismatch
    By hughesy8290 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-28-2013, 11:18 AM
  6. RunTime Error 13 and Type Mismatch...
    By TheNewGuy in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-24-2010, 09:24 AM
  7. Runtime Error Type 13 Mismatch
    By Linking to specific cells in pivot table in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-31-2006, 12:35 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1