Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Login Form  - VB6 & Access Database

Posted on 2003-03-14
8
Medium Priority
?
424 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
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
Independent Software Vendors: 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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 Month11 days, 7 hours left to enroll

564 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