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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating a simple module 1

Status
Not open for further replies.

smuthcrmnl777

Technical User
Jan 16, 2006
104
US
I have a form with a bunch of option buttons. Every single option button will require the attached code except for the first line in the code. How can I make the code a module so I do not have to repeat the code for every option button?

Thanks!!

Code:
The option buttons available are:
opt43
opt44
optWD
optCP
optMES
optPKG
optMisc

Code:
[COLOR=red]If Me!opt43 = -1 Then[/color]

    Me!optCW = 0
    Me!optSW = 0
    Me!optCO = 0
    Me!optCHEM = 0
    Me!optSK = 0
    Me!optFX = 0
    Me!optFY = 0
    Me!optALL = 0
    Me!optCW.Enabled = False
    Me!optSW.Enabled = False
    Me!optCO.Enabled = False
    Me!optCHEM.Enabled = False
    Me!optSK.Enabled = False
    Me!optFX.Enabled = False
    Me!optFY.Enabled = False
    Me!optALL.Enabled = False
    Me!btnClearBtm.Enabled = False
    If Me!optALLProjects = -1 Or Me!optCompProjects = -1 Or Me!optNewProjects = -1 Then
        Me!btnGO.Enabled = True
    Else
        Me!btnGO.Enabled = False
    End If
Else
    If Me!opt43 = 0 And Me!opt44 = 0 And Me!optWD = 0 And Me!optCP = 0 And Me!optMES = 0 And Me!optPKG = 0 And Me!optMisc = 0 Then
        Me!optCW.Enabled = True
        Me!optSW.Enabled = True
        Me!optCO.Enabled = True
        Me!optCHEM.Enabled = True
        Me!optSK.Enabled = True
        Me!optFX.Enabled = True
        Me!optFY.Enabled = True
        Me!optALL.Enabled = True
        Me!btnClearBtm.Enabled = True
    End If
End If
 
Code:
[green]'Sub routine declaration[/green]
Private Sub OptCheck(ctlOpt As Control)
    [green]'put your code in here referencing ctlOpt[/green]
End Sub

[green]'useage[/green]
Call OptCheck(opt43)

-Pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top