Connecting Tech Pros Worldwide Forums | Help | Site Map

format for naming recordset field

Mike
Guest
 
Posts: n/a
#1: Nov 13 '05
In VB I have a recordset and want to work with specific fields.

I realize I can use an index number e.g. rst(23)but I don't like using
index numbers in case I change the underlying fields or table later.

I also realize you can use a text name of field e.g. rst!"Myfield".

But where I am having trouble is when the field has a name such as
TblProducts_Location where TblProducts is the table in which the field
"Location" resides.

How do I use that name as a recordset field?

Thank you for the help in advance.


pietlinden@hotmail.com
Guest
 
Posts: n/a
#2: Nov 13 '05

re: format for naming recordset field


how about rs.Fields("My Field Name")?

teddysnips@hotmail.com
Guest
 
Posts: n/a
#3: Nov 13 '05

re: format for naming recordset field



Mike wrote:[color=blue]
> In VB I have a recordset and want to work with specific fields.
>
> I realize I can use an index number e.g. rst(23)but I don't like using
> index numbers in case I change the underlying fields or table later.
>
> I also realize you can use a text name of field e.g. rst!"Myfield".
>
> But where I am having trouble is when the field has a name such as
> TblProducts_Location where TblProducts is the table in which the field
> "Location" resides.
>
> How do I use that name as a recordset field?
>
> Thank you for the help in advance.[/color]

Why not rst!TblProducts_Location? By the way, you don't need the
quotes, but if the column name has an embedded space, or is a reserved
word, you might need to use square brackets

rst![TblProducts_Location]

HTH

Edward

Mike
Guest
 
Posts: n/a
#4: Nov 13 '05

re: format for naming recordset field


Thanks for the suggestion but it did not work. I've spent a lot of time
on this but so far unsuccessfully.

Mike S

*** Sent via Developersdex http://www.developersdex.com ***
Mike
Guest
 
Posts: n/a
#5: Nov 13 '05

re: format for naming recordset field


Thanks for the try but neither worked. I am probably stuck using
indices.

Mike S

*** Sent via Developersdex http://www.developersdex.com ***
pietlinden@hotmail.com
Guest
 
Posts: n/a
#6: Nov 13 '05

re: format for naming recordset field


That's funny, I use the Recordset.Fields("Field Name") syntax all the
time and it has NEVER failed. You must be doing something wrong. Post
your code so we can see it instead of guessing what you could be doing
wrong. It may not be the way you're referring to the fields in your
recordset at all. It could be something entirely different.
[color=blue]
>From my point of view, this is like asking for directions when you're[/color]
lost and never telling the person helping you what intersection you're
at. How exactly are we supposed to be able to help you without
explicit/complete information? Unless you show us your code, we cannot
read it, comment on it accurately, or fix it for you. But it's your
problem... no skin off my nose if you don't feel like sharing.

David W. Fenton
Guest
 
Posts: n/a
#7: Nov 13 '05

re: format for naming recordset field


Mike <mfs43@devdex.com> wrote in
news:us8Te.53$Qz6.31730@news.uswest.net:
[color=blue]
> Thanks for the suggestion but it did not work.[/color]

Well, what error did it return?

Saying "it didn't work" doesn't give us any information to make
anything other than completely speculative suggestions for the
cause, whereas the error number and error message will narrow it
down.

From the things you report to not have worked, it seems pretty clear
to me that the field is not named what you think it is.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Closed Thread