dynamically change form-loading order

E

Eelco de Vries

Hi there,
I've got a problem here: I've got an application that needs to open a chain
of forms, depending on a choice made in a previous form.
So, if a user chooses option A in form 1, then successively forms 2,3,4 and
5 need to be opened in that order, if he chooses option B, then forms 4, 2, 6
and 5 need to be opened.
I've got two tables: first the table that holds the choice together with the
description of the input forms and the order that they should be entered, and
one that holds the description of the forms and the actual names (or the
names of the subs that open them).
I now try to build an array of form names, depending on the choice. Afaik,
this works.
The problem is now that I can;t figure out how to use the array to open the
forms in that order. Each form has two buttons: previous and next.
As you can imagine, the buttons should enter the correct forms, and the
first form that is opened should always fall back to the choice-form, and the
last form opened should always enter a report-form.
The first form and the last form can vary.
How do I do this?
 
D

Damon Heron

Are you wedded to the idea that they must be separate forms? This sounds
like an ideal use of a tabbed form with the tabctl style set to NONE, with
your forms added to the pages as subforms, and previous/next buttons on the
main form to navigate thru the tabs based on the user's choice.

In the Next/Previous buttons click events, for instance, you would have
something like

Option Compare Database
Option Explicit
Dim mychoicearray(5) As Integer 'this would be your array loaded with the
tab order you want
Dim x As Integer 'this is the counter dimmed in the form module
Private Sub CmdNext_Click()
If x < 4 Then
x = x + 1
Me.TabCtl0 = mychoicearray(x)
Else
MsgBox "End of the road!", vbCritical
End if

End Sub

Private Sub CmdPrevious_Click()
If x > 0 Then
x = x - 1
Me.TabCtl0 = mychoicearray(x)
Else
MsgBox "Beginning of the road!", vbCritical
End If

End Sub

Damon
 
E

Eelco de Vries

Thanks for the quick response.
The thing is: it's not me that's wedded to that idea, the customer needs it.
We had tabbed forms, but they didn't understand that concept. They "needed"
to have separate forms, on the first form they choose a project, in the
second form they choose a kind of report, and in the subsequent forms they
need to fill in different information based on the kind of report. In the
last form they have to press a button "Make report". If they don't have that,
they're lost... :)
 
E

Eelco de Vries

I would like to do that, but how? (feel like a complete noob here)
In the first form the project is opened, and there are a few global
variables that are needed in further forms. In the subsequent forms for
instance, the project number and information is needed to be shown in the
header of some forms.
Now that is done by opening the first form with project information, keeping
it opened and setting visibility to false, and refering to it in other forms.
Same with the project report choice. In the last form, it has to be clear
what the choice was and what kind of report has to be generated.

--
Voer eendjes, geen oorlog


ruralguy via AccessMonster.com said:
Why not just open each form as it is needed?
Thanks for the quick response.
The thing is: it's not me that's wedded to that idea, the customer needs it.
We had tabbed forms, but they didn't understand that concept. They "needed"
to have separate forms, on the first form they choose a project, in the
second form they choose a kind of report, and in the subsequent forms they
need to fill in different information based on the kind of report. In the
last form they have to press a button "Make report". If they don't have that,
they're lost... :)
Are you wedded to the idea that they must be separate forms? This sounds
like an ideal use of a tabbed form with the tabctl style set to NONE, with
[quoted text clipped - 57 lines]
The first form and the last form can vary.
How do I do this?
 
E

Eelco de Vries

Yes, of course, why didn't I think of that? (no really!)
But that remains the original problem: how to open the subsequent forms in
the order that the customer wants (i.e. the forms that are needed for the
chosen report in the order that is necessary)?
I then can refer to the first (invisible) screen, I understand that (now...,
duh!).
As I was saying: sometimes I feel like a noob... :-(


--
Voer eendjes, geen oorlog


ruralguy via AccessMonster.com said:
You already have the 1st form invisible. Can't you put enough information in
that form so that each subsequent form knows what to do?
I would like to do that, but how? (feel like a complete noob here)
In the first form the project is opened, and there are a few global
variables that are needed in further forms. In the subsequent forms for
instance, the project number and information is needed to be shown in the
header of some forms.
Now that is done by opening the first form with project information, keeping
it opened and setting visibility to false, and refering to it in other forms.
Same with the project report choice. In the last form, it has to be clear
what the choice was and what kind of report has to be generated.
Why not just open each form as it is needed?
[quoted text clipped - 12 lines]
The first form and the last form can vary.
How do I do this?

--
RuralGuy (RG for short) aka Allan Bunch MS Access MVP - acXP WinXP Pro
Please post back to this forum so all may benefit.

Message posted via AccessMonster.com
 
E

Eelco de Vries

sorry, not entirely sure what you mean here...
I've got the sequence stored in an array now (option a: form 1, 2, 5, 7 and
8, option b: form 1, 4, 5, 6 and 8, option c: form 1, 7, 3, 2, 6, 5 and 8).
How do I instruct the buttons on the forms to follow that sequence? So, when
I push the next button in form 5, it will go to form 7 when option a has been
chosen, to form 6 for option c and to form 8 in option b? And subsequently
the previous button to form 2, 6 and 4?
--
Voer eendjes, geen oorlog


ruralguy via AccessMonster.com said:
Will knowing the user chose Option A be enough information to know the
sequence of forms? You can always put an invisible control on the 1st form
that is loaded with the sequence you need.
Yes, of course, why didn't I think of that? (no really!)
But that remains the original problem: how to open the subsequent forms in
the order that the customer wants (i.e. the forms that are needed for the
chosen report in the order that is necessary)?
I then can refer to the first (invisible) screen, I understand that (now...,
duh!).
As I was saying: sometimes I feel like a noob... :-(
You already have the 1st form invisible. Can't you put enough information in
that form so that each subsequent form knows what to do?
[quoted text clipped - 14 lines]
The first form and the last form can vary.
How do I do this?

--
RuralGuy (RG for short) aka Allan Bunch MS Access MVP - acXP WinXP Pro
Please post back to this forum so all may benefit.

Message posted via AccessMonster.com
 
E

Eelco de Vries

Thanks for the input.
Seems to work now. I have the formnames in an array and I open them
according to the next or previous button. Just have to watch out at the end
of the array though :)

--
Voer eendjes, geen oorlog


ruralguy via AccessMonster.com said:
I can think of a couple of ways. Create a Global Array or maybe just a table
with all of the Form names and numbers in it. Then pass the comma delimited
sequence to each form in the OpenArgs argument of the OpenForm command.
Assuming the form know who it is, the sequence should allow it to look up the
next/previous form in the table/array.
sorry, not entirely sure what you mean here...
I've got the sequence stored in an array now (option a: form 1, 2, 5, 7 and
8, option b: form 1, 4, 5, 6 and 8, option c: form 1, 7, 3, 2, 6, 5 and 8).
How do I instruct the buttons on the forms to follow that sequence? So, when
I push the next button in form 5, it will go to form 7 when option a has been
chosen, to form 6 for option c and to form 8 in option b? And subsequently
the previous button to form 2, 6 and 4?
Will knowing the user chose Option A be enough information to know the
sequence of forms? You can always put an invisible control on the 1st form
[quoted text clipped - 13 lines]
The first form and the last form can vary.
How do I do this?

--
RuralGuy (RG for short) aka Allan Bunch MS Access MVP - acXP WinXP Pro
Please post back to this forum so all may benefit.

Message posted via AccessMonster.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top