T
tonidavid5
Guest
Hi!
I’m currently building an Access 2K database to store components and one of several fields is the [MSN] or assembly serial (there can be as many as 9999 different assemblies). Each single component can be included in one, various and/or a range of assemblies (see sample table attached below).
As I didn’t want to create 9999 different fields to cover each possible assembly, I decided to store them in a [MSN] text field as a string with a similar format to that used when choosing pages to print from a range in MS Word (using colons and dashes; i.e. 1,3,10-40).
I want to build a query where the client selects the MSN serial for which he wants its full list of components.
Using VBA to build three custom functions, I’m able to extract the ‘tokens’ between colons and dashes, and tag the ones to the left and right of a dash as ‘range start’ and ‘range end’. But I’m afraid I’m stuck as to how to build the query to get all records whose [MSN] field include the desired assembly (i.e. a record whose [MSN]=”1,3,10-40” should be listed when querying for assembly “20”). I don’t find a way to compare a query parameter (i.e. “20”) against pieces of the [MSN] field rather than the whole field.
Please, any ideas as to how to design this query? There might even be other (and better) ways to design the [MSN] field so that queries are easier to build.
All help is welcome.
Regards,
Sample table:
COMPONENT MSN Assy
A 0-9999
B 1
C 2,5-10
D 10,13-20,70
E 20-9999
I’m currently building an Access 2K database to store components and one of several fields is the [MSN] or assembly serial (there can be as many as 9999 different assemblies). Each single component can be included in one, various and/or a range of assemblies (see sample table attached below).
As I didn’t want to create 9999 different fields to cover each possible assembly, I decided to store them in a [MSN] text field as a string with a similar format to that used when choosing pages to print from a range in MS Word (using colons and dashes; i.e. 1,3,10-40).
I want to build a query where the client selects the MSN serial for which he wants its full list of components.
Using VBA to build three custom functions, I’m able to extract the ‘tokens’ between colons and dashes, and tag the ones to the left and right of a dash as ‘range start’ and ‘range end’. But I’m afraid I’m stuck as to how to build the query to get all records whose [MSN] field include the desired assembly (i.e. a record whose [MSN]=”1,3,10-40” should be listed when querying for assembly “20”). I don’t find a way to compare a query parameter (i.e. “20”) against pieces of the [MSN] field rather than the whole field.
Please, any ideas as to how to design this query? There might even be other (and better) ways to design the [MSN] field so that queries are easier to build.
All help is welcome.
Regards,
Sample table:
COMPONENT MSN Assy
A 0-9999
B 1
C 2,5-10
D 10,13-20,70
E 20-9999
Last edited: