mpicco-RCS
New member
- Local time
- Yesterday, 17:15
- Joined
- Oct 4, 2012
- Messages
- 9
I have a form with 5 buttons on it. Each button is meant to select a warehouse location, so a query can be run to give an inventory report for that location. There is a separate query for each button and the OnClick event does properly modify the recordsource to give the appropriate data to the report for the location selected.
To this functionality I want the OnClick event VBA to pass the warehouse location to a textbox on the report, so the title of the report reflects that inventory location.
My code thus far is:
Private Sub Command5_Click()
Dim mySQL As String
Dim WHSE As String
mySQL = "SELECT [Master Part List].[Part Number], [Master Part List].Category, [Master Part List].Description, [Master Part List].MaterialCost, [Master Part List].Inventory, [Master Part List].Update, [MaterialCost]*[Inventory] AS [Total Cost], [Master Part List].Warehouse"
mySQL = mySQL & " FROM [Master Part List]"
mySQL = mySQL & " WHERE ((([Master Part List].Warehouse) = 'ZTE') And ((Left$([Part Number], 3)) <> '000') And (([Master Part List].Status) = 'A'))"
mySQL = mySQL & " ORDER BY [Master Part List].[Part Number];"
WHSE = "Z-Tech"
DoCmd.OpenReport "rptMain PARTS INVENTORY", acViewDesign
Reports![rptMain PARTS INVENTORY].Report.RecordSource = mySQL
DoCmd.Close acReport, "rptMain PARTS INVENTORY", acSaveYes
DoCmd.OpenReport "rptMain PARTS INVENTORY", acViewPreview
DoCmd.OpenReport "rptMain PARTS INVENTORY", acViewPreview
Reports![rptMain PARTS INVENTORY]!tbxWhseTitle = WHSE
DoCmd.Close acReport, "rptMain PARTS INVENTORY", acSaveYes
End Sub
When I get the report, the textbox is empty, instead of containing the text value for the warehouse location.
Is this a syntax problem, or is my approach wrong? Any guidance will be very much appreciated.
Thanks!
To this functionality I want the OnClick event VBA to pass the warehouse location to a textbox on the report, so the title of the report reflects that inventory location.
My code thus far is:
Private Sub Command5_Click()
Dim mySQL As String
Dim WHSE As String
mySQL = "SELECT [Master Part List].[Part Number], [Master Part List].Category, [Master Part List].Description, [Master Part List].MaterialCost, [Master Part List].Inventory, [Master Part List].Update, [MaterialCost]*[Inventory] AS [Total Cost], [Master Part List].Warehouse"
mySQL = mySQL & " FROM [Master Part List]"
mySQL = mySQL & " WHERE ((([Master Part List].Warehouse) = 'ZTE') And ((Left$([Part Number], 3)) <> '000') And (([Master Part List].Status) = 'A'))"
mySQL = mySQL & " ORDER BY [Master Part List].[Part Number];"
WHSE = "Z-Tech"
DoCmd.OpenReport "rptMain PARTS INVENTORY", acViewDesign
Reports![rptMain PARTS INVENTORY].Report.RecordSource = mySQL
DoCmd.Close acReport, "rptMain PARTS INVENTORY", acSaveYes
DoCmd.OpenReport "rptMain PARTS INVENTORY", acViewPreview
DoCmd.OpenReport "rptMain PARTS INVENTORY", acViewPreview
Reports![rptMain PARTS INVENTORY]!tbxWhseTitle = WHSE
DoCmd.Close acReport, "rptMain PARTS INVENTORY", acSaveYes
End Sub
When I get the report, the textbox is empty, instead of containing the text value for the warehouse location.
Is this a syntax problem, or is my approach wrong? Any guidance will be very much appreciated.
Thanks!