Log in form

dinobfc

New member
Local time
Today, 18:52
Joined
Feb 4, 2004
Messages
7
i have designed a form that looks up passwords in a table and enables a user to log in using the following VBA.
Private Sub Combo0_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[Name] = '" & Me![Combo0] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub

Private Sub Command4_Click()
If Text2 = Password Then DoCmd.RunMacro ("mcropenarchivefrm")

2 questions,
(1) First i want to be able to log only administrators so that they can only see the admin side and the user just use the sales
(2) Once the user has logged in i want the form to close

Please Help!!!
 
Close form and open next

Code:
DoCmd.OpenForm "frmName", acNormal
DoCmd.Close

Something like that could work, you could also very much use dimensions.
________
Montana marijuana dispensary
 
Last edited:
a.sinatra said:
Code:
DoCmd.OpenForm "frmName", acNormal
DoCmd.Close

Word of caution: DoCmd.Close is fine but it's always better to be explicit about what you are closing.

i.e.


Code:
DoCmd.Close acForm, Me.Name

or

DoCmd.Close acForm, "frmName"
 
dinobfc said:
i have designed a form that looks up passwords in a table and enables a user to log in using the following VBA.

Private Sub Combo0_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[Name] = '" & Me![Combo0] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub

First thing - Rather than rs As Object, be explicit: rs As DAO.Recordset

Set rs = Me.RecordSetClone (it's all one word)

Name is a bad name for a field - it's a reserved word in Access

""" & Me.[Combo0] & """" rather than what you had because you might have names with ' in them and . is better than ! ;)

Why waste time looping through a recordset anyway?

Use a query to open up to the exact person.
 
Do a search for my recent Login example - It's on a thread in the General section that was created by daneo2k3
 
Thanks

Mile-O-Phile said:
Do a search for my recent Login example - It's on a thread in the General section that was created by daneo2k3

Thanks a lot will do
 
Query? What Query

Mile-O-Phile said:
First thing - Rather than rs As Object, be explicit: rs As DAO.Recordset

Set rs = Me.RecordSetClone (it's all one word)

Name is a bad name for a field - it's a reserved word in Access

""" & Me.[Combo0] & """" rather than what you had because you might have names with ' in them and . is better than ! ;)

Why waste time looping through a recordset anyway?

Use a query to open up to the exact person.




How would you perform a query to do this????
 
I'd store the person's loginCode/userName in a table in a field next to their name with a a tblUsers. The criteria for the query, in the userName field would be: =Environ("username")
 

Users who are viewing this thread

Back
Top Bottom