Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Maybe you should change your approach.</p> <p>I would suggest the following:</p> <p>In the main module use a loop to cycle open the form and loop every time the user press the "Next Form" button.</p> <pre><code>'This sub in your main Module sub ShowAndCyleForms Dim FormName As String Dim MyForm as Object Dim CloseForm as Boolean FormName = "frmMyForm" do while CloseForm=False set MyForm = VBA.UserForms.Add(FormName) MyForm.Show CloseForm=MyForm.CloseStatus FormName=MyForm.strNewForm Unload MyForm Set MyForm = Nothing loop end sub </code></pre> <p>In every form, declare:</p> <pre><code>Public CloseStatus as Boolean Public strNewForm as String </code></pre> <p>In every "Next Form" button, put something like:</p> <pre><code>Private Sub btnNextForm_Click() CloseStatus=False strNewForm= NextForm(Me.Name) Me.Hide End Sub </code></pre> <p>Modify your sub to be a function that delievers the next Form Name</p> <pre><code>Sub NextForm(strFormName As String) Dim intCurPos As Integer 'Find out which form we are currently on from a list in a range intCurPos = WorksheetFunction.Match(strFormName, Range("SYS.formlist"), 0) If intCurPos = WorksheetFunction.CountA(Range("SYS.formlist")) Then 'We want to use the first one intCurPos = 0 End If 'Get the name of the form to open NewForm = WorksheetFunction.Index(Range("SYS.formlist"), intCurPos + 1) ' End Sub </code></pre> <p>You will also need to modify your O.K. to just hide the form instead of unloading it and setting the CloseStatus to true.</p> <p>The idea is to control all your forms loading/unloading from outside the from in a single procedure.</p> <p>Hope it is clear enough.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload