473,592 Members | 2,921 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

A2K - passing more than one value into a popup form

Apparently you can only do this with one value i.e Call
MyAssetLocation Zoom(Me!txtLoca tion, "Amend data")

This runs;

Public Sub MyAssetLocation Zoom(ctl As Control, formName As String)

On Error GoTo err_zoom

strFormName = formName

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

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 2484
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_FFDBAChequ es
.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_frmAssetLo cZoom
.Visible = False
.SomeControl.Va lue = 42
.SomeOtherContr ol.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_frmAssetLo cZoom
.Visible = False
.SomeControl.Va lue = 42
.SomeOtherContr ol.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.txtsom evalue
popupform.txt2 = mainform.txtsom evalue2

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 MyAssetLocation Zoom(ctl As Control, formName As String)

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

Public Sub MyAssetLocation Zoom(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 mcolObjParamSet s As VBA.Collection

Public Sub PushObjectParam Set( _
ObjectName As String, _
ParamSet As Variant _
)

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

mcolObjParamSet s.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 PopObjectParamS et( _
ObjectName As String, _
ByRef ParamSet As Variant _
)

CopyVarContent FromVar:=mcolOb jParamSets(Obje ctName), _
ToVar:=ParamSet

On Error Resume Next
mcolObjParamSet s.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(FromVa r) 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 cstrZoomFormNam e = "frmZoomVal ue"

On Error GoTo err_zoom

strFormName = formName

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

PushObjectParam Set cstrZoomFormNam e, colParams

DoCmd.openform Name:=cstrZoomF ormName, _
WindowMode:=acD ialog

'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("Resp onse") = "OK" Then
Form.Controls(C trlName).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***@mailinat or.com> wrote:
Apparently you can only do this with one value i.e Call
MyAssetLocatio nZoom(Me!txtLoc ation, "Amend data")

This runs;

Public Sub MyAssetLocation Zoom(ctl As Control, formName As String)

On Error GoTo err_zoom

strFormName = formName

DoCmd.openfo rm "frmAssetLocZoo m", , , , , acDialog, ctl.Value
If Forms!frmAssetL ocZoom.Tag <> "Cancel" Then
ctl = Forms!frmAssetL ocZoom!txtText
End If
DoCmd.Close acForm, "frmAssetLocZoo m"

exit_err_zoo m:
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 MyAssetLocation Zoom(ctl As Control, formName As String)

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

Public Sub MyAssetLocation Zoom(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!frmFormNa me1!ctlName , as you've
already done for a few other things.

Dec 22 '05 #10

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

Similar topics

6
7076
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 with the related description. This is done and is obviously not a concern. However, now I would like to make it so the corresponding row becomes highlighted (changes background colour via DOM). I imagine it can be done, but I'm at a loss for...
29
4988
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 window properly but does not pass the parameter. (this is part of a coldfusion template) <a href="##"
3
1259
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 of the cities and click 'OK'. How do I then update the underlying form (txtCity) with the correct city that was selected in the popup? Thanks
1
2213
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 be used on a number of different ASPX pages (that's why I made it a ASCX). When clicking the image button, I run simple JavaScript to open another popup ASPX page that contains a calendar control and two dropdownboxes for the time (hours :...
3
3440
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 am wanting to then use this value within an element of a form on the current page -
5
2416
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 variables value needs to be passed from the main page to this popup window ... but it isn't. why? the submit button one the PHP page is
1
3723
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 form fields allow for the item description, fee, etc. I'd like the fee field to be variable based upon which hyperlink launched the popup. So, HREF click sets a variable INPUT TYPE (hidden) named "amount" equals the variable
12
37801
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 three input fields in parent window and three in popup window parent.htm
4
5917
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 them I just set their datasource. I am guessing this is probably what is causing the problem. Is there a better way to do this? Anyway this all works happily and things show up when the record already exists but I have 2 problems ; 1) When I add...
0
8236
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
7995
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8227
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6642
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5400
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3893
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2379
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1467
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1202
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.