Zerububble
Programmer
I am trying to modify a database (That works) written by a predecessor, to be more user friendly - I need to pass four variables to a report/query.
It currently uses dialog boxes that I presume are the query asking the user for input. No forms are designed for this input. There is no provision for user input checking as far as I can see.
I am looking to use a calendar control for dates and to automatically pass two other variables.
How do I get the variables into a query ? VBA is still new to me.
Variables are ...
[From Date:]
[To Date:]
[Major Address:]
[Minor Address:]
(Found in the "WHERE" section of the following SQL string)
Current command invoking report (stDocName opens diff reports) is .................
DoCmd.OpenReport stDocName, acPreview
Query (Text is lifted from the SQL view of the design of one query)...............
SELECT Format([Dispense History]![Major],"00-"
& Format([Dispense History]![Minor],"000 "
& [CDU].[Name] & " " & [CDU].[City] & ", " & [CDU].[State] AS Location, [Dispense History].Date, [Dispense History].Formula, [Dispense History].Job, [Dispense History].Department, [Dispense History].User, [Dispense History].Quantity, [Raw Value 1]+[Raw Value 2]+[Raw Value 3] AS [Value], IIf([Raw Code 1]=0,"",Format(IIf([Quantity]=0,0,[Raw Quantity 1]/[Quantity]),"0.0%"
& " of " & [Raw Product 1]![Product Name]) & IIf([Raw Code 2]=0,"",Format(IIf([Quantity]=0,0,[Raw Quantity 2]/[Quantity]),"\and"" 0.0%"""
& " of " & [Raw Product 2]![Product Name]) & IIf([Raw Code 3]=0,"",Format(IIf([Quantity]=0,0,[Raw Quantity 3]/[Quantity]),"\and"" 0.0%"""
& " of " & [Raw Product 3]![Product Name]) AS Ingredients, [Dispense History].Result, [Dispense Results].Meaning, [Raw Product 1].[Product Name], [Raw Product 2].[Product Name], [Raw Product 3].[Product Name], [Dispense History].[Raw Quantity 1], [Dispense History].[Raw Quantity 2], [Dispense History].[Raw Quantity 3], [Dispense History].[Raw Code 1], [Dispense History].[Raw Code 2], [Dispense History].[Raw Code 3], [Dispense History].[Raw Value 1], [Dispense History].[Raw Value 2], [Dispense History].[Raw Value 3]
FROM (((([Dispense History] INNER JOIN Products AS [Raw Product 1] ON [Dispense History].[Raw Code 1] = [Raw Product 1].[Product Code]) INNER JOIN Products AS [Raw Product 2] ON [Dispense History].[Raw Code 2] = [Raw Product 2].[Product Code]) INNER JOIN Products AS [Raw Product 3] ON [Dispense History].[Raw Code 3] = [Raw Product 3].[Product Code]) INNER JOIN CDU ON ([Dispense History].Minor = CDU.Minor) AND ([Dispense History].Major = CDU.Major)) INNER JOIN [Dispense Results] ON [Dispense History].Result = [Dispense Results].Result
WHERE ((([Dispense History].Date) Between [From Date:] And [To Date:]) AND (([Dispense History].Result)<=IIf(StrComp(Left([Show exceptions? (Y,N)],1),"Y",1),0,99)) AND (([Raw Product 1].[Product Name])<>"none"
AND (([Dispense History].Major)=[Major Address:]) AND (([Dispense History].Minor)=[Minor Address:]));
It currently uses dialog boxes that I presume are the query asking the user for input. No forms are designed for this input. There is no provision for user input checking as far as I can see.
I am looking to use a calendar control for dates and to automatically pass two other variables.
How do I get the variables into a query ? VBA is still new to me.
Variables are ...
[From Date:]
[To Date:]
[Major Address:]
[Minor Address:]
(Found in the "WHERE" section of the following SQL string)
Current command invoking report (stDocName opens diff reports) is .................
DoCmd.OpenReport stDocName, acPreview
Query (Text is lifted from the SQL view of the design of one query)...............
SELECT Format([Dispense History]![Major],"00-"
FROM (((([Dispense History] INNER JOIN Products AS [Raw Product 1] ON [Dispense History].[Raw Code 1] = [Raw Product 1].[Product Code]) INNER JOIN Products AS [Raw Product 2] ON [Dispense History].[Raw Code 2] = [Raw Product 2].[Product Code]) INNER JOIN Products AS [Raw Product 3] ON [Dispense History].[Raw Code 3] = [Raw Product 3].[Product Code]) INNER JOIN CDU ON ([Dispense History].Minor = CDU.Minor) AND ([Dispense History].Major = CDU.Major)) INNER JOIN [Dispense Results] ON [Dispense History].Result = [Dispense Results].Result
WHERE ((([Dispense History].Date) Between [From Date:] And [To Date:]) AND (([Dispense History].Result)<=IIf(StrComp(Left([Show exceptions? (Y,N)],1),"Y",1),0,99)) AND (([Raw Product 1].[Product Name])<>"none"