Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

NEED HELP:dynamically passing variablesto subforms

Status
Not open for further replies.

Zirak

MIS
Feb 3, 2003
164
US
Hi,
I am trying to build a wizard structure that I'll be able to reuse.
I have the main form and a subform.
At each step, the user enters information on the subform and hits a "Next" button, the data is validated and based on the data another subform will be presented.
My problem is that I need to pass the data from the each subform to the next one, however I want to do it dynamically.
In other words I want to loop through the controls of the first subform and save it somewhere, then load the next subform and be able to access the variables from the prevoius one (somthing like the Session in ASP)

Thanks
 
Would global variables work? A search of this forum would return several threads relating to this.

[blue]"Well, once again my friend, we find that science is a two headed beast. One head is nice, it gives us aspirin and other modern conveniences,...but the other head of science is BAD! Oh, beware the other head of science, Arthur; it bites!!" - The Tick[/blue]
 
Provided the subform is just hidden (ie still open) you can browse its Controls collection.

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks for your reply.
How can I keep the subform open?

I have a main form and there is a subform field on the form and based on the process I set the "SourceObject" property of the subform.
Is there a way that I can keep the previus form open?

I used to use frames with embedded VB and load the frames through ZOrder, but aprearently access doesn't have the frame object.

Global variables won't work since I can't create them dynamically. In other words what I would like to do is to loop through the controls of the form and craeate a global variable dynamically using the control's name.

Thanks
 
You may consider to use a VBA Collection object.

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks, the collection object was what I was loooking for!
I have another question though:
How can I dynamiclly set the a Form variable to a form in the form collection by passing the form name. I tried the below but it didn't work:

Public Function UpdateProductCollection(FormName As String)
Dim ctl As Control
Dim F As Form
Set F = CurrentProject.AllForms(FormName)
For Each ctl In F.Controls
MsgBox ctl.Name
Next ctl
....
 
I tried the below but it didn't work
Any error message ? Not expected result ?

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks for your reply!
Its giving me a typemistmatch error.
When I put the mouse over the code, its getting the correct string as the form name but apprently the "CurrentProject.AllForms(FormName)" code can't set F as a Form.
The only way I can set it is to use the actual form name like FOrm_frmNewProductDuypCheck but it won't help me since I have to set the form dynamically through code.

So how can I set up a varaibel that is declared as "form" if I have the form name
 
AllForms is a collection of AccessObject objects.
You may play with the Properties property returning an AccessObjectProperties collection.
I'm afraid to instantiate a form object by its name it have to be in the Forms collection, ie open.

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
I use this code to hide my forms, but ive used it to change fonts on open forms so i think it'll work for you
Code:
Function ShowHideForms(View As Boolean)
Dim frmCurrent As Form

    For Each frmCurrent In Forms
        frmCurrent.Visible = View
    Next
If View = False Then DoCmd.Maximize
End Function
i think you would replace the frmcurrent.visible =View code with this
Code:
Dim Ctrl as Control    

For Each Ctrl in frmCurrent
    'Your code
Next
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top