Consulting

Results 1 to 3 of 3

Thread: [VBA-excel 2007] How to check if variable exist on userform

  1. #1

    [VBA-excel 2007] How to check if variable exist on userform

    Hi All,

    I have 2 different userform as origin and 1 userform as destination, 1 module to manipulate data sending.
    it need to be copy variables to destination userform variables.
    But if variables not exist in destination userform, variables will not proceed to copy.
    1) Please advise how to check if variable is exist on destination userform.
    2) How to copy those group of variable dealing with for each in loop?

    I appreciate it in advance.

    for each obj in variables in frmDest
          obj = frmOrgA.obj 'if variable exist, the variables name is same
    next obj
    frmOrgA(Userform): 3 variable (strA as string, strB as string, strC as string)
    frmOrgB(Userform): 4 variable (strA as string, strB as string, strC as string)
    frmDest(Userform): 3 variable (strA as string, strB as string, strC as string)

    ------frmOrgB(Userform)----------
    Public Sub cmdDest_Click()
    Set Tg = frmDest
    Call IncomingSync(Me, Tg)
    End Sub
    ------Global(Module)-----------
    Public Sub IncomingSync(OrgUF As Object, TgUF As Object)
    ICrun = False: ICrun = True
    TgUF.strA = OrgUF.strA ' can be use for each in?
    TgUF.strB = OrgUF.strB
    TgUF.strC = OrgUF.strC
    If not TgUF.strD is nothing Then TgUF.strD = OrgUF.strD 'can I detect if variable is exist?
    frmDest.Show
    End Sub

  2. #2
    VBAX Master Aflatoon's Avatar
    Joined
    Sep 2009
    Location
    UK
    Posts
    1,720
    Location
    There are several ways to approach this. You could use one array of values in each form and simply loop through it; you could implement interfaces that you can check and react accordingly; you could use CallByName (and ideally implement properties for the forms).
    Be as you wish to seem

  3. #3

    [VBA-excel 2007] How to check if variable exist on userform

    This is hard to make it for me, Could you show sample of code?



    Quote Originally Posted by Aflatoon View Post
    There are several ways to approach this. You could use one array of values in each form and simply loop through it; you could implement interfaces that you can check and react accordingly; you could use CallByName (and ideally implement properties for the forms).

Tags for this Thread

Posting Permissions

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