VBA ISSUE When using information on either 1 or another form (1 Viewer)

dale_j1992

Registered User.
Local time
Today, 00:49
Joined
Sep 23, 2016
Messages
26
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 :)
 

plog

Banishment Pending
Local time
Yesterday, 19:49
Joined
May 11, 2011
Messages
11,613
Or to the rescue:

If DLookup("[AccessLevelID]", "tblUser", "[UserID] = " & Forms!frmLogin!cboUser) = 1 OR Forms!RFIDLOGIN!ACCESSLVL = 1 Then


However, I would not use Dlookup, I would make it a DCount and use [AccessLevelID]=1 to the criteria portion. Then if the Dcount is more than 0 it passes. I believe if the UserID is not found there will be an error thrown.
 

Users who are viewing this thread

Top Bottom