Hey guys i have a form called frmCOMPARISON (Screenshot attached for a better idea)
this form and its subform contain a series of comboboxes and txtboxes that i want to use as filters on a query to compare data from various periods and other options.
what i am wondering is how do i get it so that i can use the same form over and over again for various periods but record in the same query e.g. i will have a query called qryCOMPARISON where i want to store both a day number which is using DateDiff(startdate,date in htrxtbl) and a seperate column for each periiod containing the amount for that day.
what i have below is my logic of how to do this but im not sure how i keep P as the new value each time i re-open my form
any suggestion on what i am trying to do would be great
this form and its subform contain a series of comboboxes and txtboxes that i want to use as filters on a query to compare data from various periods and other options.
what i am wondering is how do i get it so that i can use the same form over and over again for various periods but record in the same query e.g. i will have a query called qryCOMPARISON where i want to store both a day number which is using DateDiff(startdate,date in htrxtbl) and a seperate column for each periiod containing the amount for that day.
what i have below is my logic of how to do this but im not sure how i keep P as the new value each time i re-open my form
any suggestion on what i am trying to do would be great
Code:
Dim P as integer
‘set p to be 1 at the opening of the form for the first time
P = 1
‘sets the caption of the form to “SALES COMPARISON PERIOD (and the number of the period)
frmComparison Caption = "SALES COMPARISON PERIOD" & P
' if user press next period button do this
If cmdNExt Selected
start at period(P)
‘DayNo is the datediff of the startdate and that day
‘Period(P)Amt is the sum of total sales for that day applying all filters off frmComparison
qryCOMPARISON= (SELECT DayNo:DateDiff() "Period"& P &"Amt":(Sum HTRX_VALUE) FROM HTRXTBL WHERE "frmcomparison filters applied")
‘adds 1 for the next period if next selected
add 1 to P
close form
clear filters(dept etc)
re openform
' repeat until one of the below chosen
'if command button exit selected clear all queries and filters
if cmdexit selected clear all
'if cmdprint selected view excel graph
if print selected export to excel for "qrySALESCOMPARISON"