mikebaldam
Registered User.
- Local time
- Today, 21:50
- Joined
- Oct 29, 2002
- Messages
- 114
Here's the problem (And believe me its driving me MAD)....probably really simple but I cant seem to suss it.
I have my own Logon form with a Combo Box txtUserName to pull up the username from an Employees table. This works fine.
I want to pull the username from the form above into a field in another table.... so that when the user activates a button (in a form) thier userid is inserted into an already existing record's field.
(in this case the table EMP and field QC)
I've tried to use an update query but I cant get it to pull the username form the form (I've left the form open)
I've also been trying to do this though global variables but haven't had much luck.... (my VB is non-existant)
I'm guessing that this can be done through a amend query with a lookup to the form called frmlogon, but I can't get it to pull the data and add into an existing record.
It may be of help to show what I have so far........
below are:
logon VB
Variables VB
-----------------------------LOGON-VB------------------------------------
Private Sub Form_Click()
Option Compare Database
Private intLogonAttempts As Integer
Private Sub cmdLogin_Click()
'Check to see if data is entered into the UserName combo box
If IsNull(Me.txtUserName) Or Me.txtUserName = "" Then
MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
Me.txtUserName.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("Password", "Employees", "[ID]=" & Me.txtUserName.Value) Then
ID = Me.txtUserName.Value
GetUserName = Me![txtUserName]
'Close logon form and open Main Menu Form
' code to close form removed ****** DoCmd.Close acForm, "frmLogon", acSaveNo
DoCmd.OpenForm "Main Menu"
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 your system administrator.", vbCritical, "Restricted Access!"
Application.Quit
End If
End Sub
----------VARIABLES-VB--------------------------------------------------------
Option Compare Database
Dim PstrUserName As String
Function SetUser(UserName As String) As String
PstrUserName = UserName
End Function
Function GetUser() As String
GetUser = PstrUserName
End Function
-----------------------------------------------------------------------------------
Any help would be a huge help .....................
cheers,
Mike
________
homemade vaporizers
I have my own Logon form with a Combo Box txtUserName to pull up the username from an Employees table. This works fine.
I want to pull the username from the form above into a field in another table.... so that when the user activates a button (in a form) thier userid is inserted into an already existing record's field.
(in this case the table EMP and field QC)
I've tried to use an update query but I cant get it to pull the username form the form (I've left the form open)
I've also been trying to do this though global variables but haven't had much luck.... (my VB is non-existant)
I'm guessing that this can be done through a amend query with a lookup to the form called frmlogon, but I can't get it to pull the data and add into an existing record.
It may be of help to show what I have so far........
below are:
logon VB
Variables VB
-----------------------------LOGON-VB------------------------------------
Private Sub Form_Click()
Option Compare Database
Private intLogonAttempts As Integer
Private Sub cmdLogin_Click()
'Check to see if data is entered into the UserName combo box
If IsNull(Me.txtUserName) Or Me.txtUserName = "" Then
MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
Me.txtUserName.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("Password", "Employees", "[ID]=" & Me.txtUserName.Value) Then
ID = Me.txtUserName.Value
GetUserName = Me![txtUserName]
'Close logon form and open Main Menu Form
' code to close form removed ****** DoCmd.Close acForm, "frmLogon", acSaveNo
DoCmd.OpenForm "Main Menu"
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 your system administrator.", vbCritical, "Restricted Access!"
Application.Quit
End If
End Sub
----------VARIABLES-VB--------------------------------------------------------
Option Compare Database
Dim PstrUserName As String
Function SetUser(UserName As String) As String
PstrUserName = UserName
End Function
Function GetUser() As String
GetUser = PstrUserName
End Function
-----------------------------------------------------------------------------------
Any help would be a huge help .....................
cheers,
Mike
________
homemade vaporizers
Last edited: