referencing a dataset field name 
Author Message
 referencing a dataset field name

I recently had an occasion to reference two recordsets, through code in a
form, hwere I had defined a field in each recordset with the same name ( to
assist in documenting, maintaining system, etc).

The problem was that I could not refer to the field name unless I used it
without it being qualified by the recordset name. Is there a way to do this
 . . without having different field names in tables?

Thanx

Jim



Thu, 18 May 2000 03:00:00 GMT  
 referencing a dataset field name

Quote:
>>I recently had an occasion to reference two recordsets, through code in a

form, hwere I had defined a field in each recordset with the same name ( to
assist in documenting, maintaining system, etc).

The problem was that I could not refer to the field name unless I used it
without it being qualified by the recordset name. Is there a way to do this
. . without having different field names in tables?<<

Well, sort of. Whenever you work with any object in DAO (including fields
and recordsets), the parent object has to be in scope.

To get around the inconvenience of declaring and dealing with what feels
like a bunch of extra variables, you write a function that accepts the
parent object as an argument. Within the body of the function, you operate
on the contents of that collection; the name of the parent doesn't matter at
that point.

In your case, you might write a function like this:

Private Function FindDingo(rs as Recordset, sDingo as String) as Boolean
    With rs
        .FindFirst "[Dingo] Like '" & (sDingo) & "'"
        FindDingo = Not .NoMatch
    End With
End Function

FindDingo() finds a record in any recordset, regardless of its name. Of
course, the recordset has to have a field called "Dingo" for it to work.
(That's why I made it a private; any procedure with knowledge of outside
structures should usually be isolated...)

Adam



Thu, 18 May 2000 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. dataset : cannot fil the dataset because the field is empty

2. referencing the field name of a table

3. Access 2.0 - Referencing Field Names

4. referencing field names using a variable

5. How to reference fields w/ no property name?

6. Reference a Field Name with a variable?

7. Referencing Access 2000 Field Names and Values in Word 2000

8. How to display reference field name in Grid ?

9. Repost Code Example - using variables in field name references

10. How can I reference the field name in VB

11. Repost Code Example - using variables in field name references

12. Recordset Field Name Reference

 

 
Powered by phpBB® Forum Software