Passing Variables (1 Viewer)

Yianni

Registered User.
Local time
Yesterday, 20:37
Joined
May 15, 2017
Messages
40
I have a Dialog box that is called by a button in a subform. The dialog box allows the user to find the full path and choose a graphic file. The filepath and filename is returned to an unbound box in the dialog box. I need help in returning this path and file name to a field in the subform. (global variables,modules ??)

Thanks
 

June7

AWF VIP
Local time
Yesterday, 16:37
Joined
Mar 9, 2014
Messages
5,470
Options:

1. global variable declared in general module, dialog form sets value of the variable and code in the subform references. Show your code for opening the dialog form

2. TempVars (I've never used)

3. Code behind the dialog form sets value of textbox in the subform
 

Yianni

Registered User.
Local time
Yesterday, 20:37
Joined
May 15, 2017
Messages
40
Thanks. I guess I need to study and see what I can do.
 

StevePupel

New member
Local time
Yesterday, 20:37
Joined
Nov 13, 2007
Messages
8
You can create a text box on the parent form and set the visibility property to false. Then you can store your info in the text box. The VB code within the subform will be able to access the value. There's a number of ways you could reference the control which is storing the value you need: Forms!ParentFormName!txtHiddenTextBoxThatStoresYourValue

This will work, but only if the code is running within the scope of the subform: Me.Parent!txtHiddenTextBoxThatStoresYourValue
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 01:37
Joined
Jul 9, 2003
Messages
16,280
You can create a text box on the parent form and set the visibility property to false.

This is indeed the traditional method of transferring information between one form and another. I term it the "Yellow Box" method, in that traditionally the back color of these data transfer controls is set to "Yellow" so that they stick out like sore thumbs!

An alternative method and a one that I consider somewhat tidier is to create a Custom Property within your form. This will perform the same task without resorting to an invisible control on your form.

You can see one of these custom properties and description of it in this video:- 1) - OOP's Beginner - Intro - Nifty Access --- the custom property shown is actually one which stores an object, and not just a simple string variable.

This gives you even more potential in transferring information between forms....
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 01:37
Joined
Jul 9, 2003
Messages
16,280
Here's a Sample dB named:-
InvisibleTextBoxReplacementDemo
 

Attachments

  • InvisibleTextBoxReplacementDemo.zip
    25.8 KB · Views: 81
Last edited:

Yianni

Registered User.
Local time
Yesterday, 20:37
Joined
May 15, 2017
Messages
40
Thanks for sending the code. I unzipped it to a folder and tried it, but it didn't seem to work. anything I can do?
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 01:37
Joined
Jul 9, 2003
Messages
16,280
If you post your database to the forum I might be able to have a look at it tomorrow and if I can't get around to it I'm sure someone else will....
 

Yianni

Registered User.
Local time
Yesterday, 20:37
Joined
May 15, 2017
Messages
40
I am submitting my Code crude as it is. Thanks
 

Attachments

  • NewZip.zip
    92.3 KB · Views: 91

Cronk

Registered User.
Local time
Today, 10:37
Joined
Jul 4, 2013
Messages
2,772
Tony's code works fine. It doesn't work in your database because you have not implemented it.

You can make it work using another method suggested earlier in the thread (as you tried to do with global variable), ie
on the close button code of your dialog form, replace

PhotoOfPainting = PathString
with
forms!frmArtist.frmlPaintingsubform.form!PhotoOfPainting=Pathstring
 

Yianni

Registered User.
Local time
Yesterday, 20:37
Joined
May 15, 2017
Messages
40
Thanks so much. I got it to work. Now to clean it up and see what I can do. Your help is greatly appreciated.
 

Users who are viewing this thread

Top Bottom