Results 1 to 2 of 2

Thread: referencing objects in module

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Posts
    1,091
    Hi,

    I have a form named frmSomeForm with an object on it called ws1.

    I have a module with will reference teh ws1 object but I don't want to have to keep typing in frmSomeForm.ws1.Command in the module.. Is there an easier way of doing this, such as creating a new object out of frmSomeForm.ws1 and calling it Obj so that way I can just write Obj.Command in my module instead?

    Any help would be appreciated..

    DAn

  2. #2
    Frenzied Member
    Join Date
    Mar 2000
    Posts
    1,089
    yeah, you can do exactly that.

    in your module add this
    Code:
    Private Obj As Object
    
    Public Sub SetObj(New_Obj As Object)
    
        Set Obj = New_Obj
    
    End Sub

    then bufore you start using the code in the module execute this line (put it in a Form_Load or Sub Main)

    Code:
    Call SetObj(frmSomeForm.WS1)
    you havn't said what type of object WS1 is, if it's a textbox then replace where I've said "As Object" with "As Textbox" or whatever your object is (if it's just declared as an object you wont get the pick lists.)

    then you can just use Obj instead of frmSomeForm.WS1, this is good practice anyway as it means you can change the name of your object or what object you're working on without changing all your code, so you can use the module in a different project if you want.

    Hope it helps.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width