Printing invoices based on time and date

  • Thread starter Thread starter Mike
  • Start date Start date
M

Mike

Hi,

This posting was posted earlier, but didn't show up, I
waited almost two hours but it didn't show up, so I'm re-
posting. If my earlier posting shows up, pls forgive me,
It hasn't been intensional.

I need to print invoices based on time and date of which
materials has received or based on a range of time. I
have tried to use a query based on tblInventory and have
the user get prompted to enter date or time. I used the
follwing statement in the criteria:

Between ##date1## AND ##date2##

But the problem is that date has to be hardcoded into the
query which is not dynamic. How can I, have users to get
prompted for a reange of date what ever the date be?

OR, is there any other approach to this Inventory
printing problem to avoid overlaps between print outs as
one may want to print the whole Inventory at a different
time durin the course of a day.

Thank you in advance for your help.

Mike
 
In the OnOpen event of the report that prints the invoice, it may be easiest to pop-up a
form that will query the user for the needed information. You could then use all the
abilities of a form and coding to verify that the user has entered a valid value and
concatenate a date into a time only entry if you need to.

From here you have two options. The parameters in the query could refer to controls on the
form to get their values or you could rewrite the SQL of the query with the values
concatenated in.

To do all of this, open the form with the acDialog window mode argument. This will stop
the code from running on the report until you close or hide the form. You would have two
buttons on the form, a cancel button and an OK or Continue button. The Cancel button
should simply close the form. The code in the report should check to see if the form is
open and if it is not then Cancel the opening of the report since the user chose cancel.
The OK button would run the code to verify accurate data and prompt the user for
corrections if needed. If everything is ok, then rewrite the SQL of the query and hide the
form or just hide the form (Me.Visible = False).

To refer to controls on the form in the parameter of the query you would use something
similar to

Between Forms!frmMyPopup!txtDate1 And Forms!frmMyPopup!txtDate2

To rewrite the SQL you would concatenate the SQL of the query in code then assign it to
the query.

CurrentDb.Querydefs("qryMyQuery").SQL = strSQL

Remember to close the form when you close the report since you only hid it before.
 
Back
Top