P
Peter Hallett
I have a table which consists of a series of records, each identified by a
unique ID. In addition to the ID field, each record comprises a series of
Boolean fields named, for the sake of convenience, A, B, C, D …. M …. For
each ID, one, and only one, of the latter fields is True. The task, for a
given ID, is to identify the True field.
An apparently simply solution has the form:-
bytCount = DCount(stFieldName, “qry_Find_True_Fieldâ€)
where stFieldName is programmatically and sequentially set to “Aâ€, “Bâ€,
“C†… “M†... and the relevant ID is passed as a criterion to the query.
The code is run within a simple loop which assigns the appropriate values in
turn to stFieldName and is terminated as soon as bytCount becomes non-zero,
leaving the required field identifier in stFieldName. The problem is to find
an appropriate form for the query. It is child’s play if a separate query is
used for each field name but that rapidly gets unwieldy.
Can anyone suggest a single query that would do the job or an alternative
construction? Changing the form of the table is one possibility but that
could introduce more difficulties than it resolved.
unique ID. In addition to the ID field, each record comprises a series of
Boolean fields named, for the sake of convenience, A, B, C, D …. M …. For
each ID, one, and only one, of the latter fields is True. The task, for a
given ID, is to identify the True field.
An apparently simply solution has the form:-
bytCount = DCount(stFieldName, “qry_Find_True_Fieldâ€)
where stFieldName is programmatically and sequentially set to “Aâ€, “Bâ€,
“C†… “M†... and the relevant ID is passed as a criterion to the query.
The code is run within a simple loop which assigns the appropriate values in
turn to stFieldName and is terminated as soon as bytCount becomes non-zero,
leaving the required field identifier in stFieldName. The problem is to find
an appropriate form for the query. It is child’s play if a separate query is
used for each field name but that rapidly gets unwieldy.
Can anyone suggest a single query that would do the job or an alternative
construction? Changing the form of the table is one possibility but that
could introduce more difficulties than it resolved.