|
|
Access 2000. I have a simple form with two unbound text boxes for the user to enter a date range and a button to open a report resticted by the dates. I would like the two dates passed on to the report to show in labels when it opens. I thought a good way to do this would be to create an array with the two date values and pass the array in the openargs argument. (This may not be the best way, but this is my first venture into arrays). Access help says I can refer to the array as a whole (but doesn't explain how) when I want to refer to all the values it holds, or I can refer to its individual elements. Since there is only one openargs argument and it has to be a string, is there a way to pass the single array variable to the report's open event and then extract the two dates for use in the report? I've created the array simply enough, but Access won't let me pass it using openargs.
Dim stDocName As String Dim varDate(1) As Variant varDate(0) = Forms!frmMain.txtStartDate varDate(1) = Forms!frmMain.txtEndDate stDocName = "rptMonthlyStats" DoCmd.OpenReport stDocName, acViewPreview, , , , varDate
This generates the error: An expression you entered is the wrong data type for one of the arguments Access help says that if I declare the array as type variant, I can place a whole array in a variant resulting in a single variant variable containing the whole array. Can I not then pass this single variant in the openargs argument?
Many thanks,
Rip
|
|
OpenArgs is a single value.
You could pass a delimited string, and then use the Split() function to parse it into an array.
-- Allen Browne - Microsoft MVP. Perth, Western Australia Tips for Access users - http://allenbrowne.com/tips.html Reply to group, rather than allenbrowne at mvps dot org.
"RipperT [ at ]nOsPaM.nEt>" <<RiPpErT> wrote in message news:eTRbCljTJHA.5568[ at ]TK2MSFTNGP05.phx.gbl...
[Quoted Text] > Access 2000. I have a simple form with two unbound text boxes for the user > to enter a date range and a button to open a report resticted by the > dates. I would like the two dates passed on to the report to show in > labels when it opens. I thought a good way to do this would be to create > an array with the two date values and pass the array in the openargs > argument. (This may not be the best way, but this is my first venture into > arrays). Access help says I can refer to the array as a whole (but doesn't > explain how) when I want to refer to all the values it holds, or I can > refer to its individual elements. Since there is only one openargs > argument and it has to be a string, is there a way to pass the single > array variable to the report's open event and then extract the two dates > for use in the report? I've created the array simply enough, but Access > won't let me pass it using openargs. > > Dim stDocName As String > Dim varDate(1) As Variant > varDate(0) = Forms!frmMain.txtStartDate > varDate(1) = Forms!frmMain.txtEndDate > stDocName = "rptMonthlyStats" > DoCmd.OpenReport stDocName, acViewPreview, , , , varDate > > This generates the error: An expression you entered is the wrong data type > for one of the arguments > Access help says that if I declare the array as type variant, I can place > a whole array in a variant resulting in a single variant variable > containing the whole array. Can I not then pass this single variant in the > openargs argument? > > Many thanks, > > Rip >
|
|
Although the OpenArgs property is a variant, the Access 2003 help file indicates it must contain a string expression.
<quote> Determines the string expression specified by the OpenArgs argument of the OpenForm method that opened a form. Read/write Variant. </quote>
You'll probably need to pass a delimited string, e.g. "somedate;someotherdate", where ";" is the delimiter. You can use the Split function to convert the delimited string into an array in the Open event of the report. But, are you sure you're using Access 2000? Because my understanding is that in Access 2000 reports (unlike forms) don't have an OpenArgs property. My understanding it that that property was added to reports in a later version.
-- Brendan Reynolds
"RipperT [ at ]nOsPaM.nEt>" <<RiPpErT> wrote in message news:eTRbCljTJHA.5568[ at ]TK2MSFTNGP05.phx.gbl...
[Quoted Text] > Access 2000. I have a simple form with two unbound text boxes for the user > to enter a date range and a button to open a report resticted by the > dates. I would like the two dates passed on to the report to show in > labels when it opens. I thought a good way to do this would be to create > an array with the two date values and pass the array in the openargs > argument. (This may not be the best way, but this is my first venture into > arrays). Access help says I can refer to the array as a whole (but doesn't > explain how) when I want to refer to all the values it holds, or I can > refer to its individual elements. Since there is only one openargs > argument and it has to be a string, is there a way to pass the single > array variable to the report's open event and then extract the two dates > for use in the report? I've created the array simply enough, but Access > won't let me pass it using openargs. > > Dim stDocName As String > Dim varDate(1) As Variant > varDate(0) = Forms!frmMain.txtStartDate > varDate(1) = Forms!frmMain.txtEndDate > stDocName = "rptMonthlyStats" > DoCmd.OpenReport stDocName, acViewPreview, , , , varDate > > This generates the error: An expression you entered is the wrong data type > for one of the arguments > Access help says that if I declare the array as type variant, I can place > a whole array in a variant resulting in a single variant variable > containing the whole array. Can I not then pass this single variant in the > openargs argument? > > Many thanks, > > Rip >
|
|
"Allen Browne" <AllenBrowne[ at ]SeeSig.Invalid> wrote in message news:uJd2kvjTJHA.1164[ at ]TK2MSFTNGP03.phx.gbl...
[Quoted Text] > OpenArgs is a single value. > > You could pass a delimited string, and then use the Split() function to > parse it into an array.
And Ripper may want to use the Join() function to create the delimited string from the array in the first place.
-- Dirk Goldgar, MS Access MVP www.datagnostics.com
(please reply to the newsgroup)
|
|
|