Combo box VB help on form plz.... (1 Viewer)

barnyb3

Registered User.
Local time
Today, 23:49
Joined
Apr 21, 2008
Messages
11
I have a table of users and passwords to allow different views of a database.
I have used two textbox inputs to feed the username/passwords respectively. I want to use a combo for the users instead of a text box so that the form is updated with every addition/deletion/amednment.

This is what i am using:


Private Sub Login_Click()
Password = DLookup("[password]", "tblUsers", "[Username]='" & txtUsername & "'")

If Password = txtPassword Then

isDirector = DLookup("[isDirector]", "tblUsers", "[Username]='" & txtUsername & "'")
If isDirector = True Then
DoCmd.OpenForm "Startup Fast Cabs Director"

Else

DoCmd.OpenForm "Startup Fast Cabs"
End If

Else
MsgBox "Wrong password"
End If

End Sub


Its probably simple .I am a novice so any help appreciated.

Barny
 

KeithG

AWF VIP
Local time
Today, 15:49
Joined
Mar 23, 2006
Messages
2,592
What do you need help with? Also this is not too secure, if a user held down shift while opening the file it would open up the database window. From there the user would have full access to your db. I would suggest using User level security
 

barnyb3

Registered User.
Local time
Today, 23:49
Joined
Apr 21, 2008
Messages
11
thank you for the prompt reply.
It is just for a project and to include as a feature.

It is functioning .. i just don't know how to compare a combo selection with the text input (password) in the sub.

Also how do I use the security feature you mentioned.
Thank You in advance
Barny
 

KeithG

AWF VIP
Local time
Today, 15:49
Joined
Mar 23, 2006
Messages
2,592
Just use the combobox name instead of the text box name. For the security... goto Tools securtiy and you should see some options. Unless you are using Access 2007. For some reason MS disabled User level security in 2007.
 

barnyb3

Registered User.
Local time
Today, 23:49
Joined
Apr 21, 2008
Messages
11
I am on 2007 although my experience with other versions is practically nil.

I don't have an example of combo reference and have tried googling it.


Private Sub Login_Click()
Password = DLookup("[password]", "tblUsers", "[Username]='" & usercombo & "'")

If Password = txtPassword Then

isDirector = DLookup("[isDirector]", "tblUsers", "[Username]='" & usercombo & "'")
If isDirector = True Then
DoCmd.OpenForm "Startup Fast Cabs Director"

Else

DoCmd.OpenForm "Startup Fast Cabs"
End If

Else
MsgBox "Wrong password"
End If

End Sub



My referencing is wrong .

Barny
 

barnyb3

Registered User.
Local time
Today, 23:49
Joined
Apr 21, 2008
Messages
11
Private Sub Login_Click()
Password = DLookup("[password]", "tblUsers", "[Username]='" & usercombo.Value & "'")

If Password = txtPassword Then

isDirector = DLookup("[isDirector]", "tblUsers", "[Username]='" & usercombo.Value & "'")
If isDirector = True Then
DoCmd.OpenForm "Startup Fast Cabs Director"

Else

DoCmd.OpenForm "Startup Fast Cabs"
End If

Else
MsgBox "Wrong password"
End If

End Sub


Is that how you were meaning as it is still not working.
Cheers for your attention buddy.
 

barnyb3

Registered User.
Local time
Today, 23:49
Joined
Apr 21, 2008
Messages
11
got there eventually

sub goes like


Private Sub Login_Click()
Password = DLookup("[password]", "tblUsers", "[Username]='" & usercombo.Column(1) & "'")

If Password = txtPassword Then

isDirector = DLookup("[isDirector]", "tblUsers", "[Username]='" & usercombo.Column(1) & "'")
If isDirector = True Then
DoCmd.OpenForm "Startup Fast Cabs Director"

Else

DoCmd.OpenForm "Startup Fast Cabs"
End If

Else
MsgBox "Wrong password"
End If

End Sub




Cheers for your response it got me on the right track
barny
 

Users who are viewing this thread

Top Bottom