I have 3 tables to store information;
---
tblStudent
StuID (PK) Autonum
StuName
StuAddress
etc
---
tblEmployer
EmpID (PK) Autonum
EmpName
EmpSite
etc
---
tblStaff
StaID (PK) Autonum
StaName
StaJob
When enquiring we enter the details of the student/employer/staff. If they want to take it futrther than enquiring I want to create a login for them so they can login and see their details.
I've managed to get this to work using the code below that checks the data entered in the username (cboEmployer) and password (txtPassword) boxes of the form match what is stored in the table and if it is opens a set form, but I have to open a seperate login window depending on if it is an employer/student/staff member trying to login.
'Check to see if data is entered into the UserName combo box
If IsNull(Me.cboMarketing) Or Me.cboMarketing = "" Then
MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
Me.cboMarketing.SetFocus
Exit Sub
End If
'Check to see if data is entered into the password box
If IsNull(Me.txtPassword) Or Me.txtPassword = "" Then
MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
Me.txtPassword.SetFocus
Exit Sub
End If
'Check value of password in tblEmployees to see if this
'matches value chosen in combo box
If Me.txtPassword.Value = DLookup("MktPassword", "tblMarketing", _
"[MktID]=" & Me.cboMarketing.Value) Then
MktID = Me.cboMarketing.Value
'Close logon form and open splash screen
DoCmd.OpenForm "frmMarketing", , , , , , Me![cboMarketing]
DoCmd.Close acForm, "frmMarketingLogon", acSaveNo
Else
MsgBox "Password Invalid. Please Try Again", vbOKOnly, _
"Invalid Entry!"
Me.txtPassword.SetFocus
End If
'If User Enters incorrect password 3 times database will shutdown
intLogonAttempts = intLogonAttempts + 1
If intLogonAttempts > 3 Then
MsgBox "You do not have access to this database.Please contact admin.", _
vbCritical, "Restricted Access!"
Application.Quit
End If
What I want to be able to do is have one form that will check all 3 tables and open a form based on which table they are found in.
Firstly is this possible and, if so, how do I go about it?
I am by no means an expert at this stuff so any help will be greatly appreciated!
---
tblStudent
StuID (PK) Autonum
StuName
StuAddress
etc
---
tblEmployer
EmpID (PK) Autonum
EmpName
EmpSite
etc
---
tblStaff
StaID (PK) Autonum
StaName
StaJob
When enquiring we enter the details of the student/employer/staff. If they want to take it futrther than enquiring I want to create a login for them so they can login and see their details.
I've managed to get this to work using the code below that checks the data entered in the username (cboEmployer) and password (txtPassword) boxes of the form match what is stored in the table and if it is opens a set form, but I have to open a seperate login window depending on if it is an employer/student/staff member trying to login.
'Check to see if data is entered into the UserName combo box
If IsNull(Me.cboMarketing) Or Me.cboMarketing = "" Then
MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
Me.cboMarketing.SetFocus
Exit Sub
End If
'Check to see if data is entered into the password box
If IsNull(Me.txtPassword) Or Me.txtPassword = "" Then
MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
Me.txtPassword.SetFocus
Exit Sub
End If
'Check value of password in tblEmployees to see if this
'matches value chosen in combo box
If Me.txtPassword.Value = DLookup("MktPassword", "tblMarketing", _
"[MktID]=" & Me.cboMarketing.Value) Then
MktID = Me.cboMarketing.Value
'Close logon form and open splash screen
DoCmd.OpenForm "frmMarketing", , , , , , Me![cboMarketing]
DoCmd.Close acForm, "frmMarketingLogon", acSaveNo
Else
MsgBox "Password Invalid. Please Try Again", vbOKOnly, _
"Invalid Entry!"
Me.txtPassword.SetFocus
End If
'If User Enters incorrect password 3 times database will shutdown
intLogonAttempts = intLogonAttempts + 1
If intLogonAttempts > 3 Then
MsgBox "You do not have access to this database.Please contact admin.", _
vbCritical, "Restricted Access!"
Application.Quit
End If
What I want to be able to do is have one form that will check all 3 tables and open a form based on which table they are found in.
Firstly is this possible and, if so, how do I go about it?
I am by no means an expert at this stuff so any help will be greatly appreciated!