need help with code

riddicule123

Registered User.
Local time
Today, 06:31
Joined
May 27, 2015
Messages
29
hi, im building a database for mailing/ complaints/ faults (access 2007) and i need help with the vba (i think#) on it.

ok so i have multiple forms and tables including a (loginform) which works fine, this users choose their name and type a password and it directs them to the (Mail merge) form. but im finding it hard that when a user selects their name it automatically auto fills a box, text or combo with the same username. i need to know if their is a way that when a user selects their (cbousername) that it will auto populate boxes on other forms with the same detail.

im very basic when it comes to access and would need any coding written out in the easiest way possible.

i have tried these:
Anotherform![fieldname] = Me![fieldname]
Me.(textbox/combo box name) = Me.cbousername.Column(1) - only works on the same form

please help :banghead:
 
Best solution to this problem is to never close the login form, instead hide it....
That way you can fetch the information from the login form at form open.

I think the syntax should be...
Me![Fieldname] = Forms("Loginformname")![Fieldname]
 
thank you but where would i put the sytax and how would i hide the loginform after the user uses it i currently have this on my cmdlogin button:

Private Sub cmdLogin_Click()
'Check to see if data is entered into the strAgent combo box
If IsNull(Me.cbousername) Or Me.cbousername = "" Then
MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
Me.cbousername.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 Agent to see if this
'matches value chosen in combo box
If Me.txtPassword.Value = DLookup("strPassword", "Agent", _
"[lngEmpID]=" & Me.cbousername.Value) Then
AgentID = Me.cbousername.Value
'Close loginform and open Mail merge
DoCmd.Close acForm, "loginform", acSaveNo
DoCmd.OpenForm "Mail merge"
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

End Sub
 
Simply use Me.Hide (I believe it was) to hide the form.... instead of closing it

Suggest you retrieve the username on "demand" when ever you need it.
 

Users who are viewing this thread

Back
Top Bottom