473,385 Members | 1,782 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.

A2K - passing more than one value into a popup form

Apparently you can only do this with one value i.e Call
MyAssetLocationZoom(Me!txtLocation, "Amend data")

This runs;

Public Sub MyAssetLocationZoom(ctl As Control, formName As String)

On Error GoTo err_zoom

strFormName = formName

DoCmd.openform "frmAssetLocZoom", , , , , acDialog, ctl.Value
If Forms!frmAssetLocZoom.Tag <> "Cancel" Then
ctl = Forms!frmAssetLocZoom!txtText
End If
DoCmd.Close acForm, "frmAssetLocZoom"

exit_err_zoom:
Exit Sub

err_zoom:
MsgBox Err.Description & " " & Err.number
Resume exit_err_zoom
End Sub

To put this into context, I have a form with a single field. The user
selects a value and clicks edit. A popup form appears with this value ready
to be edited. The above code handles all of that nicely.

I'd love to be able to do this with more than one value. Any ideas? I'm
looking at taggedvalues from the Access 2000 Developers Handbook but not
having much luck.

thanks
Martin
Dec 22 '05 #1
13 2446
I posted some air code in response a while ago. It hasn't shown up yet. To
assure that it does so immediately, I'll post something else:

Sub blah2()

' the form is call FFDBACheques
' it has a module
' or at least the HasModule Property set to True

With Form_FFDBACheques
.Visible = False
.txtfldDate = VBA.Date
.txtfldAmount = 1000
.Tag = "Whatever"
.Visible = True
End With

End Sub

--
Lyle Fairfield
Dec 22 '05 #2
Air code (assumes frmAssetLocZoom's HasModule property has been set to
true);

With Form_frmAssetLocZoom
.Visible = False
.SomeControl.Value = 42
.SomeOtherControl.Value = "Hi there, I am a Leo. What's your sign?"
.... whatever
.Visible = True
End With

Dec 22 '05 #3
Lyle Fairfield wrote:
Air code (assumes frmAssetLocZoom's HasModule property has been set to
true);

With Form_frmAssetLocZoom
.Visible = False
.SomeControl.Value = 42
.SomeOtherControl.Value = "Hi there, I am a Leo. What's your sign?"
.... whatever
.Visible = True
End With


Hmm, where does this With structure go? Also i'm trying to assign the
values of an underlying form to the popup form, so;

popupform.txt1 = mainform.txtsomevalue
popupform.txt2 = mainform.txtsomevalue2

I can't assign hardcoded values.
Dec 22 '05 #4
If I'm understanding the problem and objective correctly (which I am
prone to neglecting), you want to pass a bunch of values to your
subroutine, which will then populate your form's textboxes with the
passed-in values.

Apparently I definitely have missed the true goal here because it seems
way too simple. However, I will post my solution to this problem
regardless, in the interest of public humor.

Your subroutine signature is thus:
Public Sub MyAssetLocationZoom(ctl As Control, formName As String)

Is there a reason you can't just stick in some extra variables there?
I.e:

Public Sub MyAssetLocationZoom(ctl As Control, formName As String,
Optional val1 as String="", Optional val2 as String="")

Then you could simply populate your fields with the passed-in values.

As I said before, I must be missing something because I KNOW the other
posters in this thread must have already thought of adding more
variables to the sub sig.

Dec 22 '05 #5
Before I launch into the answer, I notice you're passing the name of a form
and control to a zoom form, so it can read/write the control value. To me,
the better structure would be to have the function handle reading/writing the
control and pass only the text value to and from the popup. It doesn't change
your question much though, because you still might have to pass text longer
than what OpenArgs will take.

Also, since you're passing the control object, why do you need the form name?
You could write the value back to the control and not care what form it
happens to be on. For code like this that's likely to be called from an event
handler, though, I actually like to pass the form object, and the control
name, then all the error handling responsibility is in the generic function, -
even if the control cannot be referenced.

One last thing - why is Asset Location's zoom different than anything else's
zoom? Couldn't it just be Zoom?

So...

As you've noticed, since you're opening the form as acDialog, you can't write
data to the form's controls after opening it because your code is already
waiting for the form to close when the calling code could run to do that. You
have no choice but to write the values to some kind of variable storage, then
have the dialog form read values from that storage when it opens. A similar
problem occurs trying to pass multiple parameters to a report.

I like to do it sort of like this (untested)...
== In a public module ===

Private mcolObjParamSets As VBA.Collection

Public Sub PushObjectParamSet( _
ObjectName As String, _
ParamSet As Variant _
)

'Make sure any old set is removed first
On Error Resume Next
mcolObjParamSets.Remove
On Error Goto 0: Err.Clear

mcolObjParamSets.Add Key:=ObjectName, _
Item:=ParamSet

End Sub

'Return via reference parameter, so it will work
'the same regardless of whether it's an object or
'a scalar or array.
Public Sub PopObjectParamSet( _
ObjectName As String, _
ByRef ParamSet As Variant _
)

CopyVarContent FromVar:=mcolObjParamSets(ObjectName), _
ToVar:=ParamSet

On Error Resume Next
mcolObjParamSets.Remove
On Error Goto 0: Err.Clear

End Sub

'Copies the content of one variable to another
'regardless of whether the content is an object
'or an non-object value.
Public Sub CopyVarContent( _
FromVar As Variant, _
ByRef ToVar As Variant _
)
If IsObject(FromVar) Then
Set ToVar = FromVar
Else
ToVar = FromVar
Endif
End Sub
== Code to open the dialog ===

Public Sub ZoomValue(Form As Form, CtrlName As String, Caption As String)
Const cstrZoomFormName = "frmZoomValue"

On Error GoTo err_zoom

strFormName = formName

Dim colParams As New VBA.Collection
colParams.Add Key:="Text", _
Item:=Form.Controls(CtrlName).Value
colParams.Add Key:="Caption", _
Item:=Caption

PushObjectParamSet cstrZoomFormName, colParams

DoCmd.openform Name:=cstrZoomFormName, _
WindowMode:=acDialog

'rather than hiding itself, so we can examine its state,
'The form modifies the params object to return data,
'and closes. That way we don't have to couple this code
'to the form's design implementation.
If colParams("Response") = "OK" Then
Form.Controls(CtrlName).Value = colParams("Text")
End If

proc_final:
Exit Sub

err_catch:
MsgBox Err.Description & " " & Err.number
Resume proc_final

End Sub
=====

I don't have time to type the rest of an example right now, but the zoom form
will pop the parameter set collection, and use the items in it to initialize
itself. On return, it will delete and replace the "Text" item in the
collection and add the "Response" item to say what button was pushed.
On Thu, 22 Dec 2005 12:57:30 -0000, "Deano" <de***@mailinator.com> wrote:
Apparently you can only do this with one value i.e Call
MyAssetLocationZoom(Me!txtLocation, "Amend data")

This runs;

Public Sub MyAssetLocationZoom(ctl As Control, formName As String)

On Error GoTo err_zoom

strFormName = formName

DoCmd.openform "frmAssetLocZoom", , , , , acDialog, ctl.Value
If Forms!frmAssetLocZoom.Tag <> "Cancel" Then
ctl = Forms!frmAssetLocZoom!txtText
End If
DoCmd.Close acForm, "frmAssetLocZoom"

exit_err_zoom:
Exit Sub

err_zoom:
MsgBox Err.Description & " " & Err.number
Resume exit_err_zoom
End Sub

To put this into context, I have a form with a single field. The user
selects a value and clicks edit. A popup form appears with this value ready
to be edited. The above code handles all of that nicely.

I'd love to be able to do this with more than one value. Any ideas? I'm
looking at taggedvalues from the Access 2000 Developers Handbook but not
having much luck.

thanks
Martin


Dec 22 '05 #6
On Thu, 22 Dec 2005 08:33:19 -0800, Steve Jorgensen <no****@nospam.nospam>
wrote:

....
As you've noticed, since you're opening the form as acDialog, you can't write
data to the form's controls after opening it because your code is already
waiting for the form to close when the calling code could run to do that. You
have no choice but to write the values to some kind of variable storage, then
have the dialog form read values from that storage when it opens. A similar
problem occurs trying to pass multiple parameters to a report.

I like to do it sort of like this (untested)...

....

David Fenton is likely to chime in that a wrapper object would be an even
better implementation, and he'll be right. If I have time, I'll post another
example that uses the same idea and a wrapper object instead of a collection
for passing the arguments back and forth.
Dec 22 '05 #7
Steve Jorgensen wrote:
Also, since you're passing the control object, why do you need the
form name? You could write the value back to the control and not care
what form it happens to be on. For code like this that's likely to
be called from an event handler, though, I actually like to pass the
form object, and the control name, then all the error handling
responsibility is in the generic function, - even if the control
cannot be referenced.
Oh the form name is just for the form caption.

One last thing - why is Asset Location's zoom different than anything
else's zoom? Couldn't it just be Zoom?
You're right there, it makes no odds at the moment and I am reusing it for
other forms, so it would be neater if it was just called Zoom.

So...


<snipped code>

Cripes, thank you very very much for all that. I will need a while to
digest it but it looks interesting.

Mucho thanks.
Dec 22 '05 #8
Steve wrote:
If I'm understanding the problem and objective correctly (which I am
prone to neglecting), you want to pass a bunch of values to your
subroutine, which will then populate your form's textboxes with the
passed-in values.

Apparently I definitely have missed the true goal here because it
seems way too simple. However, I will post my solution to this problem
regardless, in the interest of public humor.

Your subroutine signature is thus:
Public Sub MyAssetLocationZoom(ctl As Control, formName As String)

Is there a reason you can't just stick in some extra variables there?
I.e:

Public Sub MyAssetLocationZoom(ctl As Control, formName As String,
Optional val1 as String="", Optional val2 as String="")

Then you could simply populate your fields with the passed-in values.

As I said before, I must be missing something because I KNOW the other
posters in this thread must have already thought of adding more
variables to the sub sig.


To be honest I think it is quite simple and I have sorted out a hacked
solution using public variables, which knowing the way I code, probably
isn't the best way of doing it.

I don't know where I read it but it did say you can't pass more than one
control value across and you have to use tags or the way I did it
presumably. I haven't seen your above syntax so I will give that a go as
well.

Thanks.
Dec 22 '05 #9
I haven't got a clue about whether you can pass more than one Control
object into a subroutine. However, you could just pass the text values
of your controls into the sub. I do know you can only pass one object
into OpenArgs, if that's what you mean - but you can pass, say, a
comma-delimited string into OpenArgs and parse it out on the receiving
side. If you're trying to get values from the second form into the
first, you can use the syntax Forms!frmFormName1!ctlName , as you've
already done for a few other things.

Dec 22 '05 #10
Steve Jorgensen <no****@nospam.nospam> wrote in
news:ng********************************@4ax.com:
On Thu, 22 Dec 2005 08:33:19 -0800, Steve Jorgensen
<no****@nospam.nospam> wrote:

...
As you've noticed, since you're opening the form as acDialog, you
can't write data to the form's controls after opening it because
your code is already waiting for the form to close when the
calling code could run to do that. You have no choice but to
write the values to some kind of variable storage, then have the
dialog form read values from that storage when it opens. A
similar problem occurs trying to pass multiple parameters to a
report.

I like to do it sort of like this (untested)...

...

David Fenton is likely to chime in that a wrapper object would be
an even better implementation, and he'll be right. If I have
time, I'll post another example that uses the same idea and a
wrapper object instead of a collection for passing the arguments
back and forth.


Saved me the post!

In any event, for zoom I just use the built-in one from the wizard,
using the technique from A97 that was made possible by MS's very
kind decision to allow Getz & Litwin et al. to release the wizard
source code in the ADH97. It still works in A2K, but I've not used
it in any version beyond that. It is called like this in A97/A2k:

Application.Run("UTILITY.BuilderZoom", strObjName, strCtlName, _
strCurrValue, strFontName, intFontWeight, intFontSize)

For the general problem, though, I definitely vote for wrappers of
some sort, whether a full class module, or just some kind of wrapper
function.

It's too bad that OpenArgs is a string argument only, since then you
could pass arrays through it.

On the other hand, perhaps you could pass it a delimited list and
parse that into an array (I've been dealing with exactly that in a
PHP application I'm using, and it's pretty helpful).

But, of course, that's basically what the ADH Tag code does, and I
object to that, so I'm not certain why this alternative appeals to
me. Perhaps I've not thought it through properly.

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
Dec 22 '05 #11
"Deano" <de***@mailinator.com> wrote in
news:43***********************@ptn-nntp-reader03.plus.net:
Steve Jorgensen wrote:
Also, since you're passing the control object, why do you need
the form name? You could write the value back to the control and
not care what form it happens to be on. For code like this
that's likely to be called from an event handler, though, I
actually like to pass the form object, and the control name, then
all the error handling responsibility is in the generic function,
- even if the control cannot be referenced.


Oh the form name is just for the form caption.


Why not use ctl.Parent.Name?

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
Dec 22 '05 #12
"Steve" <th*********@gmail.com> wrote in
news:11**********************@o13g2000cwo.googlegr oups.com:
If I'm understanding the problem and objective correctly (which I
am prone to neglecting), you want to pass a bunch of values to
your subroutine, which will then populate your form's textboxes
with the passed-in values.

Apparently I definitely have missed the true goal here because it
seems way too simple. However, I will post my solution to this
problem regardless, in the interest of public humor.

Your subroutine signature is thus:
Public Sub MyAssetLocationZoom(ctl As Control, formName As String)

Is there a reason you can't just stick in some extra variables
there? I.e:

Public Sub MyAssetLocationZoom(ctl As Control, formName As String,
Optional val1 as String="", Optional val2 as String="")

Then you could simply populate your fields with the passed-in
values.

As I said before, I must be missing something because I KNOW the
other posters in this thread must have already thought of adding
more variables to the sub sig.


Well, assuming you're opening the zoom form as a dialog, how do you
pass multiple values into it? Short answer: you can't, without
overloading OpenArgs or using an outside storage structure (which is
what Steve suggested).

Your approach works only when you're not using a dialog,

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
Dec 22 '05 #13
"Steve" <th*********@gmail.com> wrote in
news:11*********************@z14g2000cwz.googlegro ups.com:
I haven't got a clue about whether you can pass more than one
Control object into a subroutine. However, you could just pass the
text values of your controls into the sub. I do know you can only
pass one object into OpenArgs, if that's what you mean - but you
can pass, say, a comma-delimited string into OpenArgs and parse it
out on the receiving side. If you're trying to get values from the
second form into the first, you can use the syntax
Forms!frmFormName1!ctlName , as you've already done for a few
other things.


Wouldn't we all assume that a zoom form would be opened modally, as
a dialog? If so, then you couldn't assign values after it opened,
because execution pauses until the dialog is closed or hidden.

Thus, the only alternatives are to overload OpenArgs (which is
messy) or to use an outside data structure. This latter is my
preference, using a class module, but you could use a custom
collection, too, with or without a wrapper class.

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
Dec 22 '05 #14

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

Similar topics

6
by: veganeater | last post by:
Hi Everyone, I was wondering if there was a way to pass a variable to a popup window. The purpose is make it so when a user clicks on a specific region/link of the glossary page, a popup opens...
29
by: wayne | last post by:
Hey there... I'm having some problems passing url parameters with an open.window command. I'm not terribly familiar with java script but here is the code below. When executed it opens the...
3
by: Chris | last post by:
Hi, On my form, when the user hit submit it validates the zip code and if more than one city is returned it pops up a form with the list of cities in a list box. The user then have to select one...
1
by: billy | last post by:
Ok, here's the situation... I have a user control that contains two textboxes (one for a from date/time and one for a to date/time) and two image buttons. The user control itself is supposed to...
3
by: michael | last post by:
let me keep it clean, quick and simple. I am passing a variable into another window and am reassigning the value on the new page - window.document...value = opener.document. ....value and...
5
by: Steve | last post by:
Hi, I currently have a problem passing a variable value from one page to another. Once a form submit button is pressed java pops up a window and displays some information. The problem being is...
1
by: Wolfman | last post by:
Hi gang! I've been searching for a solution to this problem extensively but nothing really hits the mark. I have a descriptive popup page that contains a PayPal order button. The normal PayPal...
12
meenakshia
by: meenakshia | last post by:
hi forum i have read a lot of articles regarding passing data from popup to parent up but i m looking for the opposite that is from parent to popup window pls help me in this regard i have...
4
by: John Sheppard | last post by:
Hello there I was wondering if anyone could help me, I am trying to pass a typed dataset to a dialoged child form by reference. I have binding sources sitting on the child form. So to refresh...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.