?
Solved

Login Form  - VB6 & Access Database

Posted on 2003-03-14
8
Medium Priority
?
421 Views
Last Modified: 2013-12-25
Hi,

I was wondering if anyone could help me with this seemingly easy problem.

I am creating a log in form for an application, which the user puts their employee no. in txtempno field, and password in txtpassword field. After clicking the cmdlogin button, the application should look at the database table and find the employee whose employee no matches the value of txtempno, then see if the password matches.

The problem I'm having with it is I keep getting a "Syntax error in FROM clause" statement. I have tried every possible combination of apostrophes, but all to no avail!

Please could someone help me figure out this seemingly simple, yet frustrating query!

The code I have written is below, any questions, feel free to ask.

Thanks a bunch,

Steve.

Private Sub cmdlogin_Click()
Dim db As New ADODB.Connection
Dim rs As ADODB.Recordset
Dim pw As String
pw = txtempno
db.Open "provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=R:\Dissertation Files\Data Base\a97DBase.mdb;"
Set rs = db.Execute("select * from Password where Employee_No = '" & txtempno & "'")
If rs!Password <> txtpassword Then
MsgBox "Wrong Password. Please enter again", vbOKOnly, "Log In"
db.Close
End If
End Sub
0
Comment
Question by:steve_blade
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 

Author Comment

by:steve_blade
ID: 8139994
Please ignore the pw variable in the code!!
0
 
LVL 1

Expert Comment

by:ayufans
ID: 8140781
I think it shouldn't be

select * from password

what is the name of the field on the table where the password is located ??

for example. If the table name is password, and it has the following fields :

employee_no
pass

then you should do the following :

"select pass from password where employee_no = '" & txttempno & "'"

Maybe something like that ?

Good Luck
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 8149750
>> "select * from Password where Employee_No = '" & txtempno & "'"

Employee_No is an integer, I guess. Then, please don't provide the enlcosing single quotes as you have in your query.

"select * from Password where Employee_No = " & txtempno & "" ' quotes removed

Hope that helps, as long as the name of the table is Password.

Mayank.

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:steve_blade
ID: 8154402
Mayank,

I have tried what you said. Unfortuantely, I am still getting the same "Syntax error in FROM clause" message again. You are correct, the Employee_No is an integer, if this makes any difference.

This should be so simple though!

Does anyone else have any ideas?

Thanks,

Steve.
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 8156691
Please post your updated query statement (and specify the data types of the variables and attributes).

Mayank.
0
 

Accepted Solution

by:
steve_blade earned 0 total points
ID: 8157692
I've figured it out - I changed the Jet version from 4.0 to 3.51. Works fine now!

A big all-round "Doh!" to me, and thanks to you!

Cheers for your help,

Steve.
0
 
LVL 2

Expert Comment

by:cerebralpc
ID: 9085605
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Accept mayankeagle   comment as answer.

Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
cerebralPC
EE Cleanup Volunteer
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 9085795
Well my comment didn't relly help as he figured it out himself. If he wishes, he can also close the question and get the points refunded (if possible).

Thanks,

Mayank.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month15 days, 6 hours left to enroll

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question