>Could anyone help me out with these codes. Something is wrong but I can't
>figure it out.
[quoted text clipped - 17 lines]
>
>Any help will be greatly appreciated. Thank you.
Yes. There are 4 scnerios. And I need all the args to be in the same
positions depending one if which I am using.
DoCmd.OpenForm "Invoice by Dates", acNormal, acWindowNormal,
OpenArgs:=Me.txtStartDate.Value & "," & Me.txtEndDate.Value
DoCmd.OpenForm "Invoice by Dates", acNormal, acWindowNormal,
OpenArgs:=Me.txtStartDate.Value & "," & Me.txtEndDate.Value & "," &
Me.cmbVendor.Value & "," & Me.cmbReviewer
DoCmd.OpenForm "Invoice by Dates", acNormal, acWindowNormal,
OpenArgs:=Me.txtStartDate.Value & "," & Me.txtEndDate.Value & "," &
Me.cmbVendor.Value
DoCmd.OpenForm "Invoice by Dates", acNormal, acWindowNormal,
OpenArgs:=Me.txtStartDate.Value & "," & Me.txtEndDate.Value & "," & "," &
Me.cmbReviewer.Value
> You do realize that in your code you have the comma twice, yes?
> & "," & ","
[quoted text clipped - 22 lines]
> >
> >Any help will be greatly appreciated. Thank you.
Tom van Stiphout - 07 Dec 2007 12:54 GMT
As long as you realize that, your code is OK. THe debugger can confirm
this.
Personally I don't do it this way. Rather I create a querystring-like
string:
OpenArgs:="StartDate=" & Me.txtStartDate.Value & "&EndDate=" &
Me.txtEndDate.Value etc.
Then I write the code once to parse such string into a dictionary
object, and use it for all my forms and all my projects. I like the
fact that the string becomes self-describing and I haven't had a
parsing error in years (last time was with embedded & characters,
which I solved the same way as on the web: urlencode/decode).
-Tom.
>Yes. There are 4 scnerios. And I need all the args to be in the same
>positions depending one if which I am using.
[quoted text clipped - 40 lines]
>> >
>> >Any help will be greatly appreciated. Thank you.
Ayo - 07 Dec 2007 14:39 GMT
Thanks Tom. But how do I use them when I hope the other.
form.OpenArgs:="StartDate=" & Me.txtStartDate.Value & "&EndDate=" &
Me.txtEndDate.Value etc.
For example in the form_load event I you suggesting that I use this:
Private Sub Form_Load()
Me.txtStartDate.Value = StartDate
Me.txtSEndDate.Value = EndDate
> As long as you realize that, your code is OK. THe debugger can confirm
> this.
[quoted text clipped - 54 lines]
> >> >
> >> >Any help will be greatly appreciated. Thank you.
Ayo - 07 Dec 2007 15:44 GMT
Is there an exmple you can show me on how to do this dictionary object. I
have never used it before and reading the description in the help file, I am
still not sure how it would work for me or how to go about ctreating it for
my particular situation.
> As long as you realize that, your code is OK. THe debugger can confirm
> this.
[quoted text clipped - 54 lines]
> >> >
> >> >Any help will be greatly appreciated. Thank you.
Tom van Stiphout - 08 Dec 2007 03:30 GMT
A dictionary object is a collection of name/value pairs, just like a
querystring is.
You can turn the querystring into a dictionary object by using the
Split function to split on "&", and then within each element use the
Split function again to split on "=".
You'll need to read up on the Scripting.Dictionary object to find out
how to use it. I see it as an array on steroids: you can add
name/value pairs (.Add), you can test for existence (.Exists), and of
course get the value of a particular element (.Value).
To apply this to your situation: once you have the dictionary object
there is no more need to find the commas. Rather you would write code
like this:
dim dtStartDate as Date
dtStartDate = dict("StartDate").Value
if dict.Exists("Vendor") then
intVendorID = dict("Vendor")
-Tom.
>Is there an exmple you can show me on how to do this dictionary object. I
>have never used it before and reading the description in the help file, I am
[quoted text clipped - 59 lines]
>> >> >
>> >> >Any help will be greatly appreciated. Thank you.