473,503 Members | 2,120 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Parameter box when try to preview report

56 New Member
Expand|Select|Wrap|Line Numbers
  1. Sub PreviewReport_Click()
  2. On Error GoTo Err_PreviewReport_Click
  3.  
  4.     Dim stRepName As String:    Rem Holds the Report name
  5.     Dim stDispId  As String:    Rem Holds the Dispenser ID
  6.     Dim stQuery   As String:    Rem Holds the Query name
  7.     Dim stWhere   As String:    Rem Holds the where clause
  8.     Dim stExtra   As String:
  9.     Dim stMonthYear, stYear, stWeekCount As String
  10.     Dim intX As Integer, rst As Recordset
  11.     Dim dtEndDate As Date
  12.  
  13.     stRepName = Form.cbReports
  14.  
  15.     If IsNull(Form.cbDispenser) Then
  16.        MsgBox ("Please pick a Dispenser.")
  17.        GoTo Exit_PreviewReport_Click
  18.     End If
  19.  
  20.     stDispId = Form.cbDispenser
  21.     stWhere = ""
  22.  
  23.     If IsNull(Form.cbMonthYear) Then
  24.         MsgBox ("Please pick a Month")
  25.         GoTo Exit_PreviewReport_Click
  26.     Else
  27.         stMonthYear = Form.cbMonthYear
  28.         stYear = Format(CDate("1 " & Form.cbMonthYear), "yyyy")
  29.     End If
  30.  
  31.  
  32.     dtEndDate = Nz(DMax("EndDate", "Dispensers", "[ID] = " & stDispId), cLowDate)
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39. If stRepName = "Weekly Dispenser Sales" Then
  40.     stQuery = "Weekly Dispenser Sales"
  41.     stWhere = "format(START_DT,""MMMM YYYY"") = """ + stMonthYear + """"
  42. ElseIf stRepName = "Individual Weekly Sales" Then: Rem Sheet 8
  43.     If dtEndDate <> cLowDate And _
  44.         Format(dtEndDate, "YYYYMMDD") < Format(CDate(cbMonthYear), "YYYYMMDD") Then
  45.  
  46.             MsgBox ("There are no records for this Dispenser in this month")
  47.         Exit Sub
  48.  
  49.     Else
  50.         stQuery = "Individual Weekly Sales"
  51.        stWhere = "SALES.DISPENSER_ID = " + stDispId + " and format(START_DT,""MMMM YYYY"") = """ + stMonthYear + """"
  52.     End If
  53. ElseIf stRepName = "Company Weekly Sales" Then
  54.     stQuery = "Company Weekly Sales"
  55.  
  56.  
  57. ElseIf stRepName = "Company Monthly Sales" Then
  58.     stQuery = "Company Monthly Sales"
  59.  
  60. ElseIf stRepName = "Company Year End" Then
  61.     stQuery = "Company Year End"
  62.     stWhere = "SALES.WorkingWeek=-1"
  63. ElseIf stRepName = "Dispenser Comparison Monthly" Then: Rem Sheet 11
  64.     stQuery = "Dispenser Comparison Monthly"
  65.  
  66. ElseIf stRepName = "Dispenser Comparison Yearly" Then
  67.     stQuery = "Dispenser Comparison Yearly"
  68.     stWhere = "Year= " & stYear & " and SALES.WorkingWeek =-1"
  69. ElseIf stRepName = "Individual Monthly Sales" Then
  70.     If dtEndDate <> cLowDate And _
  71.         Format(dtEndDate, "YYYY") < Format(CDate(cbMonthYear), "YYYY") Then
  72.  
  73.         MsgBox ("There are no records for this Dispenser in this year")
  74.         Exit Sub
  75.     Else
  76.         stQuery = "Individual Monthly Sales"
  77.         stWhere = "DISPENSER_ID=" & stDispId
  78.     End If
  79. ElseIf stRepName = "Individual Year End" Then
  80.     stQuery = "Individual Year End"
  81.     stWhere = "DISPENSERID=" & stDispId & " and SALES.WorkingWeek = -1"
  82. End If
  83.  
  84. DoCmd.OpenReport stRepName, acPreview, stQuery, stWhere
  85.  
  86. Exit_PreviewReport_Click:
  87.     Exit Sub
  88.  
  89. Err_PreviewReport_Click:
  90.     MsgBox Err.Description
  91.     Resume Exit_PreviewReport_Click
  92.  
  93. End Sub
  94.  
hey guys the above code is for a preview report button on a main menu.

one of the options for the report is to pick a report type, the pick the dispenser, the the month

so for example INDIVDUALmonthley SALES , JOE BLOGS for the month of JUNE.


so i would like it to look in the weekly sales report, extract the sales for JOE BLOGS for the month of june to be displayed.

below is the query im trying to use to extract the information


Expand|Select|Wrap|Line Numbers
  1.  
  2. SELECT DISTINCTROW SALES.DISPENSER_ID, DISPENSERS.FORENAME + " " + DISPENSERS.SURNAME AS Dispenser, format(START_DT,"mmmm") AS [Month], format(START_DT,"yyyy") AS [Year], Sum(SALES.WorkingWeek)*-1 AS NoOfWeeks, count(format(START_DT,"mmmm yyyy")) AS PETE, Sum(SALES.SALES) AS TotalSales, Sum(SALES.SALES_UNITS) AS TotalSalesUnits, Sum(SALES.PHILIPS) AS TotalPhilips, iif(Sum(Sales)=0,0,Sum(DONE)/Sum(SALES)) AS SellingAppDone, iif(Sum(Sales)=0,0,Sum(BOOKED)/Sum(SALES)) AS SellingAppBooked, iiF(Sum(SALES_UNITS)=0,0,Sum(SALES_VALUE)/Sum(SALES_UNITS)) AS AvgPrice, Sum(SALES_VALUE)/Sum(SALES.WorkingWeek)*-1 AS AvgSalesPerWeek, IIF(Sum(SALES_UNITS)-Sum(SALES)=0,0,Sum(SALES)/(Sum(SALES_UNITS)-Sum(SALES))) AS BinauralSales, Sum(SALES_VALUE) AS TotalSaleValue, null AS LessCancelled, Sum(FITTED_UNITS) AS FittedUnits, Sum(FITTED_VALUE) AS FittedValue, null AS LessCancel, Sum(DONE) AS AppDone, Sum(BOOKED) AS AppBooked, Sum(DONE)/Sum(SALES.WorkingWeek)*-1 AS AvgPerWeekDone, Sum(BOOKED)/Sum(SALES.WorkingWeek)*-1 AS AvgPerWeekBooked, cDate('1 ' & format(START_DT,"mmmm") & " " & format(START_DT,"yyyy") ) AS OrdDate
  3. FROM PERIOD INNER JOIN (DISPENSERS INNER JOIN SALES ON DISPENSERS.ID = SALES.DISPENSER_ID) ON PERIOD.ID = SALES.PERIOD_ID
  4. GROUP BY SALES.DISPENSER_ID, DISPENSERS.FORENAME, DISPENSERS.SURNAME, format(START_DT,"mmmm"), format(START_DT,"yyyy")
  5. ORDER BY SALES.DISPENSER_ID, cDate('1 ' & format(START_DT,"mmmm") & " " & format(START_DT,"yyyy") ), cDate('1 ' & format(START_DT,"mmmm") & " " & format(START_DT,"yyyy") );
  6.  
  7.  
  8.  

but im getin a parmeter box which is asking for me to enter parameter value cDate('1 ' & format(START_DT,"mmmm") & " " & format(START_DT,"yyyy") ) ?? i have no idea why.

i get parmeter boxes when i try and preview alot of the reports.................its so confusing, i dont kno were to start looking
Mar 28 '07 #1
6 1829
Rabbit
12,516 Recognized Expert Moderator MVP
but im getin a parmeter box which is asking for me to enter parameter value cDate('1 ' & format(START_DT,"mmmm") & " " & format(START_DT,"yyyy") ) ?? i have no idea why.
That's because you're trying to sort by a field that doesn't exist. If you look at the SORT BY statement of your SQL you will see 2 calculated fields that don't exist and hence you can't sort by them.
Mar 28 '07 #2
DavidOwens
56 New Member
That's because you're trying to sort by a field that doesn't exist. If you look at the SORT BY statement of your SQL you will see 2 calculated fields that don't exist and hence you can't sort by them.

so take the ORDER BY off and it should work,
. but would that let me pick a report, chose a dispenser by say 12/05/02-17/05/02 and will display the sales for that period?
Mar 28 '07 #3
DavidOwens
56 New Member
so take the ORDER BY off and it should work,
. but would that let me pick a report, chose a dispenser by say 12/05/02-17/05/02 and will display the sales for that period?
no adivce?
Mar 29 '07 #4
Rabbit
12,516 Recognized Expert Moderator MVP
so take the ORDER BY off and it should work,
. but would that let me pick a report, chose a dispenser by say 12/05/02-17/05/02 and will display the sales for that period?
Filtering for a records within a range of dates is never done through the ORDER BY as ORDER BY only sorts the records returned. If you want to filter for a date range you do it through the WHERE clause.
Mar 29 '07 #5
DavidOwens
56 New Member
Filtering for a records within a range of dates is never done through the ORDER BY as ORDER BY only sorts the records returned. If you want to filter for a date range you do it through the WHERE clause.

ideas? please
Apr 1 '07 #6
Rabbit
12,516 Recognized Expert Moderator MVP
Well, to filter for a range of dates it would be WHERE #Date1# AND #Date2#.
Apr 1 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

3
12975
by: Aaron | last post by:
Hello, I'm trying to limit a report to a list of parameters that I pass in. The report and the underlying query both use the column FirstName. Whenever I try to limit the FirstName in via the...
3
10736
by: bruce | last post by:
Hello, In Access 2003 one can use OpenReport with the acDialog parameter to open a report modally. However, doing this prevents the report's toolbars from displaying. Is there a way around...
5
2389
by: teddysnips | last post by:
I have been asked to look at an Access application. It generates a report successfully, so that you can see it on the screen with no errors. However, when you try to print it, the prompt dialog...
7
4617
by: TC | last post by:
I've produced an Access application for a client. For one report, text gets cut-off at the right margin when we print the report. It does this only when we print; it doesn't happen when we view the...
2
5412
by: mudman04 | last post by:
Hi, I searched online for some similar issues that I am facing but was not able come up with anything. I am fairly new with Access (2 months experience) and I am trying to remove a message...
6
12451
by: fieldja | last post by:
I have a form called OwnerForm. It contains a combo box called Owner. The combo box looks up names from a table called OwnerName. It contains fields called OwnerID and Owner. I also have a main...
1
4110
by: Ben | last post by:
NooB: Anyone help with what I could be doing incorrectly here? Trying to have a parameter drop down list where a user can select one or more of the available values contained in the table to...
1
5043
by: waltnixon | last post by:
I've got an MS Access query which runs fine when double clicked and returns all of the rows in a test database I'm building. I've set up a multi group report based on the query. I immediately...
11
7294
by: Gord | last post by:
When I open a certain report, it runs some code that generates the records that will be displayed in that report. This works fine. When I go to print preview the report it appears that the code...
0
7204
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7282
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
5586
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5018
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4680
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3162
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1516
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
741
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
391
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.