Results 1 to 5 of 5
  1. #1
    dale_j1992 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2016
    Posts
    8

    Wink Using a VBA code if there is two options and it could be one of either.

    Good Afternoon Everyone.


    I am relatively new to VBA, so any help would be greatly appreciated .


    I have got a database where there is two options to LOG in, one being a password the other is done using a RFID CARD, this is all working perfectly.


    My issue comes when i need to isolate what each user can access within my data base, i have got code that works for either or but i dont understand how to write the code to work with both methods.


    The two codes are


    1.
    If DLookup("[AccessLevelID]", "tblUser", "[UserID] = " & Forms!frmLogin!cboUser) = 1 Then
    DoCmd.OpenForm "Admin MENU", acNormal
    DoCmd.Close acForm, "Main Menu", acSaveYes
    Else
    MsgBox "You do not have Access to this Form!", vbOKOnly


    2.


    If Forms!RFIDLOGIN!ACCESSLVL = 1 Then
    DoCmd.OpenForm "Admin MENU", acNormal
    DoCmd.Close acForm, "Main Menu", acSaveYes
    Else
    MsgBox "You do not have Access to this Form!", vbOKOnly


    I need to somehow combined the two options so if the first was not the method used to sign in it will continue with the vba and use the second option.


    many thanks in advance.


    kind regards

  2. #2
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Code:
        If DLookup("[AccessLevelID]", "tblUser", "[UserID] = " & Forms!frmLogin!cboUser) = 1 Then
            DoCmd.OpenForm "Admin MENU", acNormal
            DoCmd.Close acForm, "Main Menu", acSaveYes
        Else
            If Forms!RFIDLOGIN!ACCESSLVL = 1 Then
                DoCmd.OpenForm "Admin MENU", acNormal
                DoCmd.Close acForm, "Main Menu", acSaveYes
            Else
                MsgBox "You do not have Access to this Form!", vbOKOnly
            End If
        End If

  3. #3
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Altho both statements are doing the same thing, is that what you want?

    Code:
        If DLookup("[AccessLevelID]", "tblUser", "[UserID] = " & Forms!frmLogin!cboUser) = 1 Or Forms!RFIDLOGIN!ACCESSLVL = 1 Then
            DoCmd.OpenForm "Admin MENU", acNormal
            DoCmd.Close acForm, "Main Menu", acSaveYes
        Else
            MsgBox "You do not have Access to this Form!", vbOKOnly
        End If

  4. #4
    dale_j1992 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2016
    Posts
    8
    Quote Originally Posted by aytee111 View Post
    Altho both statements are doing the same thing, is that what you want?

    Code:
        If DLookup("[AccessLevelID]", "tblUser", "[UserID] = " & Forms!frmLogin!cboUser) = 1 Or Forms!RFIDLOGIN!ACCESSLVL = 1 Then
            DoCmd.OpenForm "Admin MENU", acNormal
            DoCmd.Close acForm, "Main Menu", acSaveYes
        Else
            MsgBox "You do not have Access to this Form!", vbOKOnly
        End If

    Thanks for the Reply,i did try both these options and the command button just doesn't do anything :/.

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Did you debug? Set a breakpoint in the procedure, see if the code actually runs.

    How did you create the procedure? Did you select [Event Procedure] in the button click event and then click the ellipsis to open the VBA editor?
    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.

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

Similar Threads

  1. msgbox with 3 options
    By gstylianou in forum Access
    Replies: 4
    Last Post: 01-02-2014, 10:28 AM
  2. yes or no options
    By madhu in forum Access
    Replies: 3
    Last Post: 04-18-2013, 07:31 AM
  3. Subform Setup Issues (Possibly Code Related Options)
    By Scyclone in forum Programming
    Replies: 7
    Last Post: 11-07-2011, 07:26 AM
  4. Sub parameters with options
    By dssrun in forum Programming
    Replies: 2
    Last Post: 07-27-2011, 08:59 AM
  5. Grouping Options
    By Desstro in forum Queries
    Replies: 1
    Last Post: 06-20-2010, 06: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