Hi All

I need to create a login screen for a project in ms access.

I have the Visual Basic which has been installed by default along with the MS Access package.

I have designed a form in MS ACCESS for login and I ahve also created the login table in access.

When I click the login button it should check the username & pwsd in the database table and then it should allow the user to view the next form.

But it's not working.

Could anyone please help for proceeding further.

Thanks in advance

To be more precise, you have Visual Basic for Applications, VBA for short and more than likely it is version 6.5. As for helping you further, what code have you written so far?

Good Luck

Hi

in the click event of the button I ahve written the following code...
Private Sub loginclick_Click()

Dim login_tab As New Form_login_tab
Dim usertxt As Variant
'Dim txtpswd As Variant
Username1 = txtuser.Text
Password1 = txtpswd.Text


If Username = "Username1" And Pswd = "Password1" Then
MsgBox ("Message")

End If


End Sub

and I dont know how to conntect the database

Okay, lets start with your code...

#1 Why decleare a new form login from within the login form (Dim Login_Tab...). It is unneeded..
#2 You declare usertxt as variant but do not use it
#3 Next line commented out
#4 Where is username1 declared? I thought from within access if the control did not have the focus you had to use txtuser.value and not txtuser.txt
#5 see #4
$6 Okay, where is username declared? Where is pswd declared? Why are you trying to evaluate these variables to constants?

Perhaps a quick search with your friends (yahoo, google, ask, answers, bing) for vb6 ado tutorial will help you alot. Look for the vb6.us or whatever it is as they have lots of tutorials that will not only help you with connecting to your database, but with your code structure and logic. You may also want to search for vba forums or access forums while your at it as I know sites like tek-tips have both...

Good Luck

Hi mayasumi,
As pointed out by vb5prgrmr, your code is not going to work at all. there are so many errors in your code. After correcting all errors mentioned by vb5prgrmr then you can use DLookUp function or Select statement of SQL to check your username and password stored in your table.
thankx

This article has been dead for over six months. Start a new discussion instead.