RE: Build A User Defined STR Statement Using Access 2000



Thank you very much Klatuu,

To make it easier on my self (this is the second database I have ever
written), and the fact that I doubt whether there would ever be more than a
few codes to check, I will use the text field method. In your example;

strCatCodes = "IN (" & Left(strCatCodes, Len(strCatCodes) -1) & ")" Am I
right in saying this would work a bit like, "Is "Sean" in the string
"DavidSeanPaul"?

I have taken an extract from a query which I currently use to find specific
items, would you mind very much incorporating the statemet above into the
query below so that I can use it.

SELECT dbo_dimItems.MainDescription, dbo_trnBillingDetail.Qty
FROM dbo_trnBillingDetail INNER JOIN dbo_dimItems ON
dbo_trnBillingDetail.ItemID = dbo_dimItems.ItemID
WHERE (((InStr([ItemNo],"Z470")+InStr([CatalogCode],"Z470"))<>0));


In the method you suggest,

"Klatuu" wrote:

First, I would Dim a module level variable to hold the string of catalogue
codes. For example purposes, I will call it strCatCodes


Something like this in the After Update event of the control where catalogue
codes are entered:

strCatCodes = strCatCodes & Me.CatalogueCode & ","

Then, to prepare it for the query:

strCatCodes = "IN (" & Left(strCatCodes, Len(strCatCodes) -1) & ")"

Now, as to saving it for later use, you could use one of two approaches.
One would be to save it to a text field in a table so you could retrieve it
when you want to add it to your query as a where condition. The only problem
you may run into would be possibly creating a string longer than 255 bytes.

The other would be to use the CreateQueryDef method. For this, you would
have to create a complete query that you can save as a stored query with a
name unique to the promotion. Then save the name of the query in a table
with other promotion data so you call it later.

I would use the CreateQueryDef way to avoid the 255 byte limit.



"SEAN DI''''ANNO" wrote:

Good morning,

can come one please help me with my following datasbase dilemma

The user will be asked, "What Catalogue Code do you require ?" The
question will be repeated until there are no more catralogue codes. I would
like to build up a STR statement in the background.

Suppose the user enters 2 Catalogue Codes;

E.G Item 1, Item 2. I would like a variable to buld up a resulting STR
statement of

code]InStr([CatalogCode],"Item1")+InStr([CatalogCode],"Item2")[/code].

I then want the database to automatically build a query with the STR
statement so that it can be used again. The reason being.........The
database will be used to track different promotions and therefore have a
different STR statment for each promotion.

As always, If you could give me the basic skeleton code, if its possible?, I
would really appreciate it.

Thank you.
.



Relevant Pages

  • Using VBA to merge complex data
    ... I have a Word XP document with merge codes. ... source is several tables from my database. ... query to get all of the data into a single table to use as my merge data ... Mergefields in code to achieve this? ...
    (microsoft.public.word.mailmerge.fields)
  • Re: Group and Count
    ... got the Group By to be in my design view but I'm confused as to how to ... My database is something like this: ... I only want to group zip codes and then count the number in each group. ... query in the design view. ...
    (microsoft.public.access.queries)
  • Using iif condition
    ... I am working on a query that has a created column based on one column with ... codes in a lookup list from a table in the database. ... Purpose_of_Travel should come up with travel purpose based on some codes. ...
    (microsoft.public.access.queries)
  • Re: DBMS and lisp, etc.
    ... Naively implemented with SQL, again for 10 ... (1 query for the initial orders, 1 query for each order for its ... soon as you upgrade to the SQL database. ... (eq (order-customer orderA) ...
    (comp.lang.lisp)
  • Re: OT: SQL
    ... query processing. ... FROM Employees e, Employees m, Management mgt ... Manager and Employee Salaries. ... The scheme used does not model database files in general, ...
    (sci.logic)