
Signature
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
> Yes. I agree that a *field* for each possible answer is a lousy design.
> However, I don't have any control over that. The database already exists.
[quoted text clipped - 92 lines]
>> > do
>> >> > that?
> So you do want all these fields, but you don't want to pass all the fields
> into the function?
That is correct. I don't want to pass in all of fields individually.
> The only other option would seem to be to open a recordset, so the function
> itself can loop through the Fields of the Recordset to get the count of
> items.
In Delphi, I would simply pass in (a reference to) the table and then
process the fields in the current record of the table. This would be a very
low overhead operation. Is there anything equivalent that can be done in
Access/VBA?
Dan
> Opening a recordset for each item will be a very inefficient approach
> though.
[quoted text clipped - 12 lines]
> >> There is a better way to design surveys than that. Duane Hookom has an
> >> example here:
http://www.rogersaccesslibrary.com/Otherdownload.asp?SampleName='At%20Your%20Sur
vey%202000'
> >> > Allen,
> >> >
[quoted text clipped - 76 lines]
> >> > do
> >> >> > that?
Allen Browne - 18 Jan 2006 02:09 GMT
You can pass the name of the table, and the primary key value, and then
OpenRecordset() to get the data in the particular record.
The performance issue is with the connections you need to open and close the
recordset constantly. There may be a way to avoid that. For example, if this
were happening in a report, you could declare a module level recordset
variable, initialize it in Report_Open, and close it in Report_Close. Then
at any record, you could FindFirst in the already-open recordset, and avoid
the bottleneck.
That general approach (walking an open recordset rather than constantly
opening and closing it) can also be achieved through a class module, or even
a public Recordset variable if you have a way to close it when you are done.

Signature
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
>> So you do want all these fields, but you don't want to pass all the
>> fields
[quoted text clipped - 124 lines]
>> >> > do
>> >> >> > that?