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

Set object variable in form module?

Status
Not open for further replies.

duanecwilson

Programmer
Jul 15, 2005
26
US
I have an object variable I was setting all over the place in different subs, etc of a form module. I decided to try to do it on a module wide basis, much like regular variables, but I got an error something like "Not valid outside of procedure" and the Set word was highlighted at compile time. Please let me know how I can do this, as it seems quite redundant and error prone to set it all over the place. Below is the code at the top of my Form nodule:

Option Compare Database
Option Explicit
'This is the column number from the combobox in Wave1Select that contains SRC_CUST_ID
Public intSrcCustIDidx As Integer
Dim frm As Form
Set frm = Forms!frmWave1Select
Dim cboSelection As Control
Set cboSelection = frm!cboWave1Select
Dim modcancel As Boolean
Dim strSRC_CUST_ID As String
-------------------------
Private Sub .... etc.
...
...
End Sub
-------------------------



Duane Wilson
 
Define the variables at module level, but set them in a sub or function that is called at a suitably early stage.
 
Will they stay set from sub to sub? Or will they need to be reset every time?

Duane Wilson
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top