Results 1 to 7 of 7
  1. #1
    KpAtch3s is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Sep 2015
    Posts
    6

    Blank Password Text Box Crashes Database

    Having not done any real programming since college almost 6 years ago I'm slowly picking it back up as I build a new database so my knowledge is still pretty limited to what I remember.



    Currently I have a form that is password protected by another form.
    Design goes as this:
    Main Menu>Open Password_Form>Open Inventory_Form

    Code is:

    Dim PassWord As String

    Private Sub Password_OK_Click()
    ' verify password then close password form and open inventory form
    PassWord = Password_Text
    If PassWord = "mypassword" Then
    DoCmd.Close
    DoCmd.OpenForm "Inventory"
    ' reset password text to blank and throw dialog box
    Else
    MsgBox ("You're not auathorized for Administrator access.")
    Password_Text = ""
    End If

    End Sub

    Since then I have tried the following but getting an invalid use of Null when left blank:

    ~
    Dim PassWord As String


    Private Sub Password_OK_Click()


    PassWord = Password_Text

    ' Close password form and open inventory form
    If PassWord = "amledpass" Then
    DoCmd.Close
    DoCmd.OpenForm "Inventory"

    ' Password left blank throw dialog box
    ElseIf PassWord = Empty Then
    MsgBox ("Please enter password.")
    Exit Sub

    ' Reset password text to blank and throw dialog box
    Else
    MsgBox ("You're not auathorized for Administrator access.")
    PassWord = ""
    End If


    End Sub

  2. #2
    CJ_London is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    getting an invalid use of Null when left blank:
    if it is left blank then the field is null - so you need to cater for this situation - investigate using the isnull and nz functions - easy to find if you google them. Also so far as I am aware there is not an 'Empty' value in Access vba.

  3. #3
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Issue possibly with: ElseIf PassWord = Empty

    What is Empty?

    Try: ElseIf PassWord = "" Then

    Are you aware that holding down shift key when opening db will bypass all this code?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    KpAtch3s is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Sep 2015
    Posts
    6
    Thanks, I'll check out isnull and nz functions. I initially had

    ElseIf PassWord = "" Then

    But I was getting the same error.

    Most everyone will be using Access Runtime so I'm not too concerned at the moment with the bypass. Unless I'm mistaken, correct me if I'm wrong.

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    What is Password_Text - a textbox?

    Which line is throwing the error?

    PassWord is defined as a string type. Only variant type can hold Null.

    Maybe: PassWord = Nz(Me.Password_Text,"")

    Step debug. Refer to link at bottom of my post for guidance.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    KpAtch3s is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Sep 2015
    Posts
    6
    I'll have to wait to get back work to answer most of those questions, but yes PassWord_Text is a textbox. I'll update the thread tomorrow with my results.

  7. #7
    KpAtch3s is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Sep 2015
    Posts
    6
    Quote Originally Posted by June7 View Post
    What is Password_Text - a textbox?

    Which line is throwing the error?

    PassWord is defined as a string type. Only variant type can hold Null.

    Maybe: PassWord = Nz(Me.Password_Text,"")

    Step debug. Refer to link at bottom of my post for guidance.

    Nz is exactly what I needed. It seems to have broke another function of the code though. It no longer clears Password_Text after an incorrect password is entered. I can play around with that however. I'll mark solved. Thanks!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 05-20-2014, 09:32 AM
  2. Advise needed blank database or blank Web Database
    By Derrick T. Davidson in forum Access
    Replies: 0
    Last Post: 04-25-2013, 09:13 PM
  3. Replies: 2
    Last Post: 01-30-2013, 06:48 AM
  4. Database crashes after table update
    By AccessJunkie in forum Access
    Replies: 3
    Last Post: 09-09-2011, 07:33 PM
  5. Text box crashes
    By mn1247 in forum Access
    Replies: 1
    Last Post: 06-25-2011, 01:33 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums