Hello,
I'm a college student currently studying a Database Design unit, so I apologise for being clueless in this post.
I've watched a YouTube video on how to create a simple login system using an If DCount Macro.
I have the following 2 (simplified) tables:
Staff
Account
I have the following Macro that I acquired from the aforementioned YouTube video:
This macro checks the data entered in the UName and Pwd text boxes against a Staff_Number (username) and Password combination in the Account table to determine a successful login.
However, as part of normalisation rules, I don't want to have the Staff_Number attribute in the Account table. I want DCount to use the Staff_ID (foreign key in the Account table) to get the Staff_Number from the Staff table and check it against the data entered in the UName text box. For the Password, I want it to check the Password in the Account table against the data entered in the Pwd text box (as it's already doing in the above If statement).
I've tried the following, which is a lazy attempt (as it tries to check user-input against data in two different tables) and doesn't get rejected by the Macro, but it results in a failed login attempt:
I've tried learning DCount and DLookup online but I'm just so confused by the various examples and complex ways in which it can be used. I have no idea how to implement what I'm trying to achieve. I wanted some authenticity (i.e. getting the Staff_Number by checking it against the Staff_ID in the Account table [then finding it in the Staff table] and finally checking the password against the same record).
I appreciate in advance any time taken to help me understand how this can be achieved.
I'm a college student currently studying a Database Design unit, so I apologise for being clueless in this post.
I've watched a YouTube video on how to create a simple login system using an If DCount Macro.
I have the following 2 (simplified) tables:
Staff
Staff_ID | Staff_Number | First Name | Last Name | Address | Phone Number |
1 | 101262 | Amelia | Smith | 12 Somerview Walk | 555111 |
2 | 103951 | Harold | Jenkins | 46 Oldham Avenue | |
Account
Account_ID | Staff_ID | Staff_Number | Password |
1 | 1 | 101262 | pass123 |
2 | 2 | 103591 | pass321 |
I have the following Macro that I acquired from the aforementioned YouTube video:
Code:
If(DCount("Staff_Number","Account","Staff_Number=[UName] And Password=[Pwd]"))>0
This macro checks the data entered in the UName and Pwd text boxes against a Staff_Number (username) and Password combination in the Account table to determine a successful login.
However, as part of normalisation rules, I don't want to have the Staff_Number attribute in the Account table. I want DCount to use the Staff_ID (foreign key in the Account table) to get the Staff_Number from the Staff table and check it against the data entered in the UName text box. For the Password, I want it to check the Password in the Account table against the data entered in the Pwd text box (as it's already doing in the above If statement).
I've tried the following, which is a lazy attempt (as it tries to check user-input against data in two different tables) and doesn't get rejected by the Macro, but it results in a failed login attempt:
Code:
If(DCount("Staff_Number","Staff","Staff_Number=[UName]") And DCount("Password","Account","Password=[Pwd]"))>0
I've tried learning DCount and DLookup online but I'm just so confused by the various examples and complex ways in which it can be used. I have no idea how to implement what I'm trying to achieve. I wanted some authenticity (i.e. getting the Staff_Number by checking it against the Staff_ID in the Account table [then finding it in the Staff table] and finally checking the password against the same record).
I appreciate in advance any time taken to help me understand how this can be achieved.
Attachments
Last edited: