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

Error 3075 1

Status
Not open for further replies.

Hargreavesk

Technical User
Jul 18, 2001
97
GB
Hi,

Can anyone help?

I'm using the following code:

Dim db As Database
Dim rs As Recordset
Set db = CurrentDb

Set rs = db.OpenRecordset("SELECT [Name] from [TBL ChequeDetails] where [TBL ChequeDetails].[Name]= " & (Me!Name))

Unfortunately, I'm getting an Error 3075 "Syntax error, missing operator. As I've been looking at this for a while and not been able to see anything wrong, please can someone help before i go blind?

Many thanks

Kate :eek:)
 

hello kate

Is this on a form or in a module before I go any further

regards
Jo

 
Jo,

Thanks for replying. The code I'm using is part of a search form. If I search for "Kate Hargreaves" in the field called "Name", I get this error.

Thanks

Kate
 
Kate,

I suspect that the error is occuring because you are not enclosing the name in quotes; ie.

Change the line:

Set rs = db.OpenRecordset("SELECT [Name] from [TBL ChequeDetails] where [TBL ChequeDetails].[Name]= " & (Me!Name))

to:

Set rs = db.OpenRecordset("SELECT [Name] from [TBL ChequeDetails] where [TBL ChequeDetails].[Name]= '" & (Me!Name) & "'")

or better still, cut out some of the redundant stuff; ie:

Set rs = db.OpenRecordset("SELECT [Name] from TBL ChequeDetails where [Name]= '" & Me!Name & "'")

This should do the trick,
Cheers,
Steve

PS. This code will fail if you enter a name like O'Connor. Food for thought on how you'd deal with that situation.
 


Apologies Kate

We've just had a power cut and our leccy has just kicked in

Steve has given you the same answer that I was going to offer

Talk to you again soon

regards

jo
 
Steve,

Thanks for all your help. It works perfectly!!! I'll have a think about the names problem

Jo,

Sorry about your power but Thanks anyway.

Regards

Kate
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top