Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do i solve this problem?

Status
Not open for further replies.

myaccess2000

Technical User
Aug 4, 2002
16
0
0
SG
Hi,

i have the error pop up and the error is "data type mismatch in criteria expression". It shows that there is something wrong with my SQL statement and i can't figure out what is wrong with that.

date1.text is the value in my textbox and i intend to use the date in the textbox to look for that particular record and perform deletion. What is the root cause of the above error?
i = CDate(Date1.Text)
Set dbs = CurrentDb
dbs.Execute ("DELETE FROM Pay_info where emp_date = '" & i & "'")
dbs.Close

Regards
irene
 
By using the CDate() function you have converted the text string to a date string......so you will have to compare against the date string and date strings require the # symbol.....

Try:

i = CDate(Date1.Text)
Set dbs = CurrentDb
dbs.Execute ("DELETE FROM Pay_info where emp_date = #" & i & "#")
dbs.Close

The secret to creativity is knowing how to hide your sources. - Albert Einstein [spin]

Robert L. Johnson III, A+, Network+, MCP
Access Developer/Programmer
robert.l.johnson.iii@citigroup.com
 
bingo!!...thanks! it really works!!! You are real fast in responding. :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top