Results 1 to 2 of 2
2004-01-26, 20:54 #1
- Join Date
- Feb 2002
- Thanked 0 Times in 0 Posts
Function doesnt work first time (Access 2000)
Function that works second time
I have a function that works fine, but only the second time.I mean with the first click the report is opened blank, and just when i click second time,
the function is triggered and the report is opened properly.I cannot explain myself why is it so, this is beyond me.
Since the function is working the second time, can i make it work properly
with the first click ?
Dim strCriteria As String
Dim invoicedate As Control
Dim jan As String
Dim month As Control
Set month = Me![month]
Set invoicedate = Me![invoicedate]
jan = "Month(invoicedate)= 1 and year(invoicedate) = 2004"
Select Case month
strCriteria = jan
Dim strDocName As String
strDocName = "rptMonths"
DoCmd.OpenReport strDocName, acPreview, , strCriteria
2004-01-27, 03:34 #2
- Join Date
- Dec 2000
- Sacramento, California, USA
- Thanked 1 Time in 1 Post
Re: Function doesnt work first time (Access 2000)
That's the code inside a function but it doesn't indicate any arguments that might be passed or anything else that might be going on. You also haven't included the Click event that calls the function. I assume this is in a form, but what is this for?<hr>Set month = Me![month]<hr>If you have a month control on your form, you don't need to assign it to an object variable in order to evaluate its value, which is what you appear to be trying to do in the Select Case. And if you do want to assign it to a variable, don't use a variable with the same name as the control. Access won't be sure which one you're evaluating, which may be your problem. If your month control doesn't have a value of 1, then you won't set a criteria to pass to the report as the code is presently written.Charlotte