Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 2 / December 2007

Tip: Looking for answers? Try searching our database.

Help!!!!. Code is not working correctly

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ayo - 07 Dec 2007 04:45 GMT
Could anyone help me out with these codes. Something is wrong but I can't
figure it out.
This particular line of code is suppose to have 3 OpenArgs for the form
"Invoice by Dates" but only the first two gets included. Me.cmbReviewer.Value
is not included
DoCmd.OpenForm "Invoice by Dates", acNormal, acWindowNormal,
OpenArgs:=Me.txtStartDate.Value & "," & Me.txtEndDate.Value & "," & "," &
Me.cmbReviewer.Value

This snippet of code is suppose to tell me where the first comma, the 2nd
comma and the 3rd comma are in the OpenArgs. I am not sure if I am writing it
correctly.
If IsNull(Me.OpenArgs) = False Then
   commaOne = InStr(Me.OpenArgs, ",")
   commaTwo = InStr(Mid(Me.OpenArgs, commaOne + 1), ",")
   commaThree = InStr(Mid(Me.OpenArgs, commaTwo + 1), ",")
Else
 '------ Insert Exit sub here with Msgbox ----------------'
End If

Any help will be greatly appreciated. Thank you.
Tom van Stiphout - 07 Dec 2007 04:52 GMT
You do realize that in your code you have the comma twice, yes?
& "," & ","

-Tom.

>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.
Ayo - 07 Dec 2007 05:03 GMT
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.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.