Field Names containing Spaces and the Find First method

Field Names containing Spaces and the Find First method

Post by Oscar L. Bowye » Wed, 19 Nov 1997 04:00:00



Jeremy,
        You might try putting brackets around the field name like [CLIENT NAME].
This works in Access, not sure about VB. Hope this helps.

Oscar Bowyer



Quote:> I am having trouble with the Data1.REcordset.findfirst method if the
> criteria for the search contains a field name that has a space in it.
> For example suppose you have a databse table in microsoft Access with a
> field name called CLIENT NAME.  That is two words separated by a space.
> Now suppose I want to use this code:

> Data1.Recordset.findfirst "CLIENT NAME = 'JONES'"

> It says SYNTAX ERROR.  

> But suppose you change the name of the field to CLIENTNAME with no
> space:

> data1.recordset.findfirst "CLIENTNAME = 'JONES'"

> then it works perfectly!!  What can I do if I want the space in the
> field name???

> I have tried many different things including:
> CLIENT_NAME
> "CLIENT" & " " & "NAME"
> but to no avail.

> I know this must be something simple and I have consulted books and the
> help in VB.  No luck.  HELP ME!!!

> Jeremy Beginning VB programmer

 
 
 

Field Names containing Spaces and the Find First method

Post by Kevin Evan » Tue, 25 Nov 1997 04:00:00


You must have had hundreds of replies on this one!
Just put the field name in 'square brackets':
data1.recordset.findfirst("[Client Name]='Jones'")

--
KLE

 
 
 

1. Find method fails on text field containing # character

Hi,

I'm using Find (seek is hopeless) on an Access2000 mdb to search for text
fields that match a certain string.  This works great unless the text I'm
searching for contains a pound # symbol, in which case it consistently
fails.

What does Access/ADO have against Finding text with the # character?  How
would you work around this?

Thanks,
Teller

2. VB4 DAO

3. Error accessing fields with column name containing spaces

4. Unidata FAQ Issue 2 has been sent

5. Find returns mostly blank fields for first found record (FMP5)

6. Access Developer Looking for Power!

7. How do I parse name into first and last name fields

8. Image Insert

9. Find strings that contain more than one blank space

10. Error 25 when directory name contains a space

11. spaces in table names and field names

12. Help With Find First Method

13. Find First, Find Next, Find Previous, Find Last