473,379 Members | 1,533 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

DAO criteria type mismatch error

i have coded a username password program via using DAO control
created a ms access 7.0 DB file and linked with data1 control and used 2 textbox controls for username and password.
For login cmd button i have written below codes
Dim strCritaria As String
strCritaria = " [Username] = ' " & txtuse.Text & " ' " And "[Password] = ' " & txtpass.Text & " ' "
Data1.Recordset.MoveFirst
Data1.Recordset.FindFirst (strCritaria)
If Data1.Recordset.NoMatch Then
MsgBox "Invalid Entry"
txtuse.Text = ""
txtpass.Text = ""
Else
MsgBox "Login Succussfull"
End If
in execution i am getting type mismatch runtime error 13 in strCritaria line
any help regarding this will be appreciated...
sorry i am new to vb6
Apr 15 '10 #1

✓ answered by patjones

Also be careful about padding the criteria with spaces, as you have done. The way you've written out the criteria, if they type in "zepphead80" for the user name, the criteria will read [Username] = ' zepphead80 '. If zepphead80 existed as a user in your table, it wouldn't be found. Modify the criteria as:

Expand|Select|Wrap|Line Numbers
  1. strCritaria = " [Username] = '" & txtuse.Text & "' And [Password] = '" & txtpass.Text & "'" 

which would then give you [Username] = 'zepphead80'.

Pat

3 1589
PatMc
1
Hi,
If this line of criteria is correct then change it to the line I have modified below
strCritaria = " [Username] = ' " & txtuse.Text & " ' " And "[Password] = ' " & txtpass.Text & " ' "

Modified line
strCritaria = " [Username] = ' " & txtuse.Text & " ' And [Password] = ' " & txtpass.Text & " ' "
Apr 15 '10 #2
patjones
931 Expert 512MB
Also be careful about padding the criteria with spaces, as you have done. The way you've written out the criteria, if they type in "zepphead80" for the user name, the criteria will read [Username] = ' zepphead80 '. If zepphead80 existed as a user in your table, it wouldn't be found. Modify the criteria as:

Expand|Select|Wrap|Line Numbers
  1. strCritaria = " [Username] = '" & txtuse.Text & "' And [Password] = '" & txtpass.Text & "'" 

which would then give you [Username] = 'zepphead80'.

Pat
Apr 16 '10 #3
wow guys well done
it works
thank you
PatMc & zepphead80
Apr 16 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Laurel | last post by:
this is driving me crazy. i need to use a form control as a criteria in a select query, and the control's value is set depending upon what a user selects in an option group on the form. the query...
1
by: ArcadeJr | last post by:
Good morning all! I have been getting a Run-time Error message #3464 - Data Type mismatch in criteria expression. While trying to run a query. I have a database where the field Asset_Number...
2
by: igor.barbaric | last post by:
Hello! I have created a very simple query like this: SELECT Tasks.Name, DurationHrs(,) AS Duration FROM Tasks INNER JOIN Log ON Tasks.TaskID=Log.TaskID; The above query works fine....
1
by: Igor Barbaric | last post by:
Hello! I have created a very simple query like this: SELECT Tasks.Name, DurationHrs(,) AS Duration FROM Tasks INNER JOIN Log ON Tasks.TaskID=Log.TaskID; The above query works fine....
2
by: psychomad | last post by:
Please, can someone help me out to solve this error, i've been searching throughout my codes and yet i didnt succeed in finding the error!!!! The Error is: Server Error in '/' Application....
5
by: blackburnj55 | last post by:
Hi, I am constructing a website for a bike shop. I am using dreamweaver and an access database to create it. I have made a query where two criteria are entered to get results. These are :...
19
by: Lysander | last post by:
I have written a query that takes three integers representing day,month and year, forms a date from them and compares this date to the date the record was entered and returns any records where the...
3
by: Nepenthen | last post by:
Hello – I am still new to Access and I am currently working on debugging some code. I have a form with the following: Employee Name (combo with select all choice) Task (combo with select all...
14
by: ezechiel | last post by:
Hello, I know others have the same problem here, I tried (a lot! ) different solutions but still can't get around the problem.. :s Here's the code: Private Sub cb_swedit_sopi_AfterUpdate()...
9
by: nixonmg | last post by:
When the Command Button "Notify" is clicked, I am wanting to send out an email to the user with appropriate information in the email (works great), check the "Notified" check box (does not work), and...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.