473,385 Members | 1,843 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Opening a form with 'openargs'

Hi. I am trying to open a form using 'openargs' parameter of the
docmd.openform action. The problem is that I would like to pass the
form some character (string) and integer data. My plan was to
concatenate the data with delimeters (",") between the fields. Then in
the Form_Open( ) procedure I would parse the data and fill some "global"
variables that could be used to populate some data in the form when
there are no records (and I come up with a blank New Record). The
problem is then the integer data. Is it possible to do what I want? If
so, how?

I'm a mainframe programmer who dabbles in MS/Access and VBA for fun and
I'm trying to put together a utility that some of us here at work can
use to keep track of 'tasks' within a 'project' within a 'release of
software'. This way those of us who do 'Release Management' could
generate all the reports (and excel spreadsheets) that are asked of us.
The only problem ... I have to get it working before I show it to my
bosses.

Any suggestions? Or Questions? I'll gladly get more specific if you
need. Just ask away.

Thanks.
Sue


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #1
11 5999
A better way to do this might be to only pass the string via OpenArgs and then
put a multiselect listbox on your first form where the users can select the
Integer data and then pass the Integer data to the second form from the listbox.
--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
re******@pcdatasheet.com
www.pcdatasheet.com
"Susan Bricker" <sb****@att.net> wrote in message
news:40*********************@news.frii.net...
Hi. I am trying to open a form using 'openargs' parameter of the
docmd.openform action. The problem is that I would like to pass the
form some character (string) and integer data. My plan was to
concatenate the data with delimeters (",") between the fields. Then in
the Form_Open( ) procedure I would parse the data and fill some "global"
variables that could be used to populate some data in the form when
there are no records (and I come up with a blank New Record). The
problem is then the integer data. Is it possible to do what I want? If
so, how?

I'm a mainframe programmer who dabbles in MS/Access and VBA for fun and
I'm trying to put together a utility that some of us here at work can
use to keep track of 'tasks' within a 'project' within a 'release of
software'. This way those of us who do 'Release Management' could
generate all the reports (and excel spreadsheets) that are asked of us.
The only problem ... I have to get it working before I show it to my
bosses.

Any suggestions? Or Questions? I'll gladly get more specific if you
need. Just ask away.

Thanks.
Sue


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 12 '05 #2
OpenArgs is pretty limited. Yes, you can concatenate strings, then parse them
back out, but then there's a good chance you'll soon want more, and the string
lenght is in danger of exceeding the maximum for OpenArgs.

What I've started doing is to make a global collection variable called
gcolPassArgs. Before opening a form or report to which I want to pass
arguments, I create a colleciton of arguments, and place it in the global
variable. In Open event for the form or report, grab the collection from the
globable variable, then process its contents. It is important to fully read
the colleciton or copy it to a private reference variable in the Open event
handler since other code may rewrite the data at any time in order to pass
arguments to some other form or report.

In a standard module somewhere...

Dim gcolPassArgs As VBA.Collection

In the code that opens the form...

Dim colFormParams As VBA.Collection
Set colFormParams = New VBA.Collection
colFormParams.Add Key:="Arg1", Item:="ABCD"
colFormParams.Add Key:="Arg2", Item:=123
Set gcolPassArgs = colFormParams
DoCmd.OpenForm "frmFoo"
In frmFoo...

Private Sub Form_Open(Cancel As Integer)
Me!txtData1 = gcolPassArgs("Arg1")
Me!txtData2 = gcolPassArgs("Arg2")
End Sub
On 24 Feb 2004 18:08:41 GMT, Susan Bricker <sb****@att.net> wrote:
Hi. I am trying to open a form using 'openargs' parameter of the
docmd.openform action. The problem is that I would like to pass the
form some character (string) and integer data. My plan was to
concatenate the data with delimeters (",") between the fields. Then in
the Form_Open( ) procedure I would parse the data and fill some "global"
variables that could be used to populate some data in the form when
there are no records (and I come up with a blank New Record). The
problem is then the integer data. Is it possible to do what I want? If
so, how?

I'm a mainframe programmer who dabbles in MS/Access and VBA for fun and
I'm trying to put together a utility that some of us here at work can
use to keep track of 'tasks' within a 'project' within a 'release of
software'. This way those of us who do 'Release Management' could
generate all the reports (and excel spreadsheets) that are asked of us.
The only problem ... I have to get it working before I show it to my
bosses.

Any suggestions? Or Questions? I'll gladly get more specific if you
need. Just ask away.

Thanks.
Sue


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


Nov 12 '05 #3
Susan Bricker wrote:
Hi. I am trying to open a form using 'openargs' parameter of the
docmd.openform action. The problem is that I would like to pass the
form some character (string) and integer data. My plan was to
concatenate the data with delimeters (",") between the fields. Then in
the Form_Open( ) procedure I would parse the data and fill some "global"
variables that could be used to populate some data in the form when
there are no records (and I come up with a blank New Record). The
problem is then the integer data. Is it possible to do what I want? If
so, how?

I'm a mainframe programmer who dabbles in MS/Access and VBA for fun


Good practice.

Why is integer a problem? Act as if it is a string (during its OpenArgs
voyage) and then convert the string into an integer using implicit or
explicit type conversion (does implicit not work? Never mind then) See
Int() CInt() CLng()

--
Bas Cost Budde
http://www.heuveltop.org/BasCB
but the domain is nl

Nov 12 '05 #4
Susan Bricker wrote:

and Val() of course
--
Bas Cost Budde
http://www.heuveltop.org/BasCB
but the domain is nl

Nov 12 '05 #5
Steve Jorgensen wrote:
OpenArgs is pretty limited. Yes, you can concatenate strings, then parse them
back out, but then there's a good chance you'll soon want more, and the string
lenght is in danger of exceeding the maximum for OpenArgs.

What I've started doing is to make a global collection variable called
gcolPassArgs.
I even use a special table for this. Of course global variables do not
die in a normally running application, but they will die on error (some
errors?)

I think there is an article about that on my site... yes,
articles:public variables.

Before opening a form or report to which I want to pass arguments, I create a colleciton


happy to see you have the same 'type timing' as I :-)

--
Bas Cost Budde
http://www.heuveltop.org/BasCB
but the domain is nl

Nov 12 '05 #6
On Tue, 24 Feb 2004 20:04:30 +0100, Bas Cost Budde <ba*@heuveltop.org> wrote:
Steve Jorgensen wrote:
OpenArgs is pretty limited. Yes, you can concatenate strings, then parse them
back out, but then there's a good chance you'll soon want more, and the string
lenght is in danger of exceeding the maximum for OpenArgs.

What I've started doing is to make a global collection variable called
gcolPassArgs.
I even use a special table for this. Of course global variables do not
die in a normally running application, but they will die on error (some
errors?)


They die if you ever stop the code in debug mode. In this code, the global
variable is only used briefly to transfer the data from one procedure to
another, so the fragility of global data is not a big issue.

I think there is an article about that on my site... yes,
articles:public variables.

Before opening a form or report to which I want to pass
arguments, I create a colleciton


happy to see you have the same 'type timing' as I :-)


<g>
Nov 12 '05 #7

"Steve Jorgensen" wrote
OpenArgs is pretty limited. Yes, you can
concatenate strings, then parse them
back out, but then there's a good chance
you'll soon want more, and the string
lenght is in danger of exceeding the maximum
for OpenArgs.


Strangely, perhaps, I have never come close to having to pass enough data
via OpenArgs to ever, even remotely, fear that I might one day exceed the
maximum. We must design applications differently.

Larry Linson
Microsoft Access MVP
Nov 12 '05 #8
On Thu, 26 Feb 2004 02:34:38 GMT, "Larry Linson" <bo*****@localhost.not>
wrote:

"Steve Jorgensen" wrote
OpenArgs is pretty limited. Yes, you can
concatenate strings, then parse them
back out, but then there's a good chance
you'll soon want more, and the string
lenght is in danger of exceeding the maximum
for OpenArgs.


Strangely, perhaps, I have never come close to having to pass enough data
via OpenArgs to ever, even remotely, fear that I might one day exceed the
maximum. We must design applications differently.

Larry Linson
Microsoft Access MVP


I have, on occasion, needed to pass SQL statements to forms, and these can
easily become long. In one application, the user first enters a large amount
of data about how to translate data, moving it from one database to another,
then another form manages pre-checking the data, executing the operation, and
reporting the results. I pretty much had to make a custom class to
encapsulate the data to pass, and I had to use a global variable to pass it.

Besides all that, to me the inelegance of using a global variable to pass data
is less than the inelegance of concatenating a bunch of arguments into a
string, then parsing them back out. They're both inelegant, but the parsing
relies on more code working properly and more constraints being met to work
correctly. Regarding the string length, just because it's not exceeded during
testing, can we ensure that it won't be exceeded during production? There are
just fewer concerns to worry about with the global variable.
Nov 12 '05 #9
I most often use OpenArgs to pass very minor amounts of data -- it never has
occurred to me to use them for user-entered information that could be
essentially unlimited in length or for passing SQL statements. So, maybe
it's just that I instinctively did NOT use OpenArgs for those, rather than
never had the need to pass anything that long.

I am of the "old school" that "has no great fear" of judiciously-used global
variables -- after all, in one or two of my programming incarnations, I
worked in eras when that's all there was for interroutine communication.
I've never seen the "horde of slavering, foaming-at-the-mouth programmers
just waiting to pounce on and corrupt a poor unprotected global" that some
seem to fear. A class for which a new object can be instantiated, or an
entry in an array of UDT's, is a good answer to the longer stuff, for those
who have seen the "Slavering Horde", though.

Larry Linson
Microsoft Access MVP
"Steve Jorgensen" <no****@nospam.nospam> wrote in message
news:9g********************************@4ax.com...
On Thu, 26 Feb 2004 02:34:38 GMT, "Larry Linson" <bo*****@localhost.not>
wrote:

"Steve Jorgensen" wrote
OpenArgs is pretty limited. Yes, you can
concatenate strings, then parse them
back out, but then there's a good chance
you'll soon want more, and the string
lenght is in danger of exceeding the maximum
for OpenArgs.
Strangely, perhaps, I have never come close to having to pass enough data
via OpenArgs to ever, even remotely, fear that I might one day exceed the
maximum. We must design applications differently.

Larry Linson
Microsoft Access MVP


I have, on occasion, needed to pass SQL statements to forms, and these can
easily become long. In one application, the user first enters a large

amount of data about how to translate data, moving it from one database to another, then another form manages pre-checking the data, executing the operation, and reporting the results. I pretty much had to make a custom class to
encapsulate the data to pass, and I had to use a global variable to pass it.
Besides all that, to me the inelegance of using a global variable to pass data is less than the inelegance of concatenating a bunch of arguments into a
string, then parsing them back out. They're both inelegant, but the parsing relies on more code working properly and more constraints being met to work correctly. Regarding the string length, just because it's not exceeded during testing, can we ensure that it won't be exceeded during production? There are just fewer concerns to worry about with the global variable.

Nov 12 '05 #10
rkc

"Larry Linson" <bo*****@localhost.not> wrote in message
news:9a****************@nwrddc02.gnilink.net...
I've never seen the "horde of slavering, foaming-at-the-mouth programmers
just waiting to pounce on and corrupt a poor unprotected global" that some
seem to fear. A class for which a new object can be instantiated, or an
entry in an array of UDT's, is a good answer to the longer stuff, for those who have seen the "Slavering Horde", though.


As Mr. Jorgensen has pointed out in another thread, there doesn't need to
be a horde of any kind. Just one other sane yet unaware programmer.
Nov 12 '05 #11
"Larry Linson" <bo*****@localhost.not> wrote in
news:9a****************@nwrddc02.gnilink.net:
I most often use OpenArgs to pass very minor amounts of data -- it
never has occurred to me to use them for user-entered information
that could be essentially unlimited in length or for passing SQL
statements. So, maybe it's just that I instinctively did NOT use
OpenArgs for those, rather than never had the need to pass
anything that long.

I am of the "old school" that "has no great fear" of
judiciously-used global variables -- after all, in one or two of
my programming incarnations, I worked in eras when that's all
there was for interroutine communication. I've never seen the
"horde of slavering, foaming-at-the-mouth programmers just waiting
to pounce on and corrupt a poor unprotected global" that some seem
to fear. A class for which a new object can be instantiated, or an
entry in an array of UDT's, is a good answer to the longer stuff,
for those who have seen the "Slavering Horde", though.


When I get to the point where I need to pass more than one piece of
information to a form, I will tend to do one of two things:

1. create custom public properties of the form and set those after
opening the form. This works only if it's not a dialog.

2. use a class module, either as a data storage structure or as a
wrapper around the dialog itself.

I am a firm believer in writing forms that don't themselves need to
know anything about aspects outside themselves. But, obviously,
that's not always the case. This comes up mostly in my work for
cases of dialogs that are used for filtering

Of course, there's also opening the form with acHidden, putting into
it what you need, then setting its .Modal property to True, then
setting its .Visible property to True. If I were going to do that, I
think I'd probably create a public method for the form to do all of
that, as well as using my method 1) for the things you're getting
from outside.

But, mostly, compound OpenArgs indicate a design problem, in my
opinion. The worst problem is that there's no documentation of the
structure of what you have to pass it. That's why custom properties
or a class module used as a data structure is superior, because it
can validate your input. OpenArgs simply can't do that.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 12 '05 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Not Me | last post by:
Hi, I'm opening one form from another, passing the criteria through using OpenArgs (this works correctly - I have tested with a msgbox). The problem is with the findfirst method, I get the syntax...
3
by: Jim Evans | last post by:
Using code and suggestions from an earkier thread in this group, I have created the following cond for the open event of a form I am opening from the button click event of another form. ...
3
by: cjay85 | last post by:
I have two forms - 'Application' and 'User'. Within both the 'User' and 'Application' forms I have a field called 'ID Number'. I want to be able to open up the Application form from the User...
1
by: Kevin Nechodom | last post by:
I am trying to use a consolidated filter form, where I pass the desired report I wish to run. I would like to install this form on my custom menu bars, but I can't figure out any way to pass data...
4
by: Barry Edmund Wright | last post by:
Hi All, I am using the code below to assign a form name to a form variable (vFrm). Is there a way to assign the Openargs string directly to vFrm, i.e. vFrm = Openargs ? Private Sub...
7
by: sara | last post by:
I have a form where the user selects an item from a list box, and then works on that item. The user chooses an AD, then opens a form to assign departments to the ad. The top of the Depts form has...
3
by: MartinR | last post by:
Hi, I'm still new to writing code in vba as I've only been introduced to access three weeks ago. I have written this code below and it executes but does not do what I want it to do. What I want is...
10
by: sara | last post by:
Hi - I have been struggling with solution ideas for this now for almost 2 weeks, and have not been able to figure this out. I have a user who creates a Purchase Order (tblPOData). In some...
4
by: dantebothermy | last post by:
Hi friends, I want a script that will move a form to a chosen record. Here's what I'm trying: I get the parameter from la different form using Docmd,openform using openargs I've been...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.