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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error in Recordset opening

Status
Not open for further replies.

maverickmonster

Programmer
May 25, 2004
194
GB
I have the following code in my VB6 form, defRsp takes its information from a txtbox which will contain typed date of birth. When you type a date of birth in the code goes to my error code to say record doesnt exist. the dob typed is in the table is in the database.

The dob is formated as a date/time and i can not change this.

Code:
Which = "     Select * from [BPD] where [BPD].dob =" & defRsp & " "

RSbpd.Open Which, cn, adOpenKeyset, adLockOptimistic ' open recordset

How can i rectify this so that it works ?

Many thanks in advanced

Maverickmonster
 
Depending on what database you're querying, and the datatype of the field, for dates, Access will need hash (#) as date delimiter, I think SQL server needs single quotes. If dob is text, single quotes.

[tt]...[BPD].dob =#" & defRsp & "#"[/tt]

if dob is date, you may have to format the date to an unambigous format, should your date settings differ from US.

Since this is VB, not VBA, shouldn't this rather be in the VB5/6 forum (forum222)?

Roy-Vidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top