Modules/Procedure

  • Thread starter Thread starter Chris
  • Start date Start date
C

Chris

Hi All. On the close event of many of my forms i have a case statement to
select which form to return to.

I will be using the same code on several different forms and am sure that
this code can be stored in a module but I don't know how to save/call the
module.

Select Case me.openargs
Case 1, 2
Forms!frmMain.visible = true
Case 3,4
Forms!frmManagermain.visible = true
Case 5
Forms!frmUserMain.visible = true
End Select

Thanks in advance
Enjoy the weekend
 
On the modules tab click new and then type in the following. Click the save
button on the toolbar and call the module anything you like.
In the close event of your forms, replace your existing code with
Goto_Which_Form(Me.openargs)

Function Goto_Which_Form(nArgs as Integer)
Select Case nArgs
Case 1, 2
Forms!frmMain.visible = true
Case 3,4
Forms!frmManagermain.visible = true
Case 5
Forms!frmUserMain.visible = true
End Select
End Function
 
Chris said:
Hi All. On the close event of many of my forms i have a case statement to
select which form to return to.

I will be using the same code on several different forms and am sure that
this code can be stored in a module but I don't know how to save/call the
module.

Select Case me.openargs
Case 1, 2
Forms!frmMain.visible = true
Case 3,4
Forms!frmManagermain.visible = true
Case 5
Forms!frmUserMain.visible = true
End Select

Thanks in advance
Enjoy the weekend

What you can do, is store it as a procedure in a module. For example, you
could call the procedure ShowForm, then in a module, you would create the
procedure:

Public Sub ShowForm (Arg as Integer)
Select Case Arg
Case 1, 2
Forms!frmMain.visible = true
Case 3,4
Forms!frmManagermain.visible = true
Case 5
Forms!frmUserMain.visible = true
End Select
End Sub

Then to call it from a Close Event, or wherever, you would use:

ShowForm 2

HTH,
Randy
 
Back
Top