J jketcher Registered User. Local time Today, 12:11 Joined Apr 15, 2009 Messages 77 Apr 22, 2009 #1 Hi! I have several places in my code where I am performing the same initializations. What is the syntax for setting up one routine that can be performed from multiple places in the code? Thanks, jketcher
Hi! I have several places in my code where I am performing the same initializations. What is the syntax for setting up one routine that can be performed from multiple places in the code? Thanks, jketcher
ezfriend Registered User. Local time Today, 12:11 Joined Nov 24, 2006 Messages 242 Apr 22, 2009 #2 Perhaps, you can initialize it like this. Code: Private Sub Initializations() 'intialize variables, text fields, etc.. here End Sub Then call the sub routine when need to. Code: Private Sub cmdOK_Click() Call Initializations End Sub If you want to intialize let's say combo boxes, you can put this sub routine in a module and pass in the combobox. For example, this is the one i use. Code: Public Sub ClearComboBox(ByVal cbo As ComboBox) Dim i As Long For i = cbo.ListCount - 1 To 0 Step -1 cbo.RemoveItem i DoEvents Next End Sub So each time I want to clear up the combo box I just call the function Code: ClearComboBox cboFields Last edited: Apr 22, 2009
Perhaps, you can initialize it like this. Code: Private Sub Initializations() 'intialize variables, text fields, etc.. here End Sub Then call the sub routine when need to. Code: Private Sub cmdOK_Click() Call Initializations End Sub If you want to intialize let's say combo boxes, you can put this sub routine in a module and pass in the combobox. For example, this is the one i use. Code: Public Sub ClearComboBox(ByVal cbo As ComboBox) Dim i As Long For i = cbo.ListCount - 1 To 0 Step -1 cbo.RemoveItem i DoEvents Next End Sub So each time I want to clear up the combo box I just call the function Code: ClearComboBox cboFields