Results 1 to 12 of 12
  1. #1
    2 Star Lounger
    Join Date
    Mar 2003
    Posts
    191
    Thanks
    0
    Thanked 0 Times in 0 Posts

    VB Script in Custom Form (2000/2002)

    Hi there,
    I have two fields called ComboBox2 and AddLable.
    ComboBox2 has three possible selections, they are Beijing,
    Shanghai and Hong Kong.
    The AddLable field is a multi line lable field. If the
    user selects Beijing, I want a Beijing address to populate
    this field. For example:
    14 Smith Street
    Chaoyang District
    Beijing 100028
    China

    Same thing for an address in Shanghai and Hong Kong.
    Maybe some VB code script required? Can anyone help me
    with this? Thanks in advance.

    Bill

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: VB Script in Custom Form (2000/2002)

    The VB object model has an event named CustomPropertyChange that you should in theory be able to intercept (there's a VBScript example in the online help). I played with this for a few minutes and could not get it to fire, but then, I'm not a forms person...

  3. #3
    2 Star Lounger
    Join Date
    Mar 2003
    Posts
    191
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VB Script in Custom Form (2000/2002)

    Hi all,
    I am trying to work my way through this problem. I'm getting there but need a little help.
    I have two fields called ComboBox2 and Lable15.
    ComboBox2 has three possible selections, they are Beijing,
    Shanghai and Hong Kong.
    The Lable15 field is a multi line lable field. If the
    user selects Beijing, I want a Beijing address to populate
    this field. For example:
    User selects "Oracle Beijing" from ComboBox2
    "Beijing address" appears in Lable15 field.
    I have written the following code, and although it doesn't present any errors when it is run, it doesn't populate the text "Beijing address" in Lable15 field.

    Option Explicit
    Dim Label15
    Dim ComboBox2
    Sub Item_CustomPropertyChange(ByVal Name)
    If ComboBox2 = "Oracle Beijing" Then Label15 = "Beijing Address"
    End Sub

    Can anyone help me?
    Thanks heaps in advance.

    Bill

  4. #4
    5 Star Lounger
    Join Date
    May 2001
    Location
    Washington, USA
    Posts
    750
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VB Script in Custom Form (2000/2002)

    It's gonna be more along the lines of the snippet below:

    Sub Item_CustomPropertyChange(ByBal ChangeProperty)
    Select Case ChangeProperty
    Case "ComboBox2"
    If Item.UserProperties("ComboBox2")= "Oracle Beijing" then
    Item.UserProperties("Label1") = "Beijing Address"
    End If

    If Item.UserProperties("ComboBox2")= "SAS Italy" then
    Item.UserProperties("Label1") = "Italy Address"
    End If

    End Select
    End Sub

  5. #5
    2 Star Lounger
    Join Date
    Mar 2003
    Posts
    191
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VB Script in Custom Form (2000/2002)

    Hi there,
    OldDog - Thanks heaps for your help. I have one little problem however. With the code you provided the line

    Sub Item_CustomPropertyChange(ByBal ChangeProperty)

    Generates a message that says "Expected ')' Line 3:". I can't find where the problem is. Any ideas???
    Thanks again.

    Bill

  6. #6
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: VB Script in Custom Form (2000/2002)

    Not sure what that error means, but ByBal should be ByVal (not to be confused with "buy a vowel"). Not sure if this will fix it or would be a separate issues.

  7. #7
    2 Star Lounger
    Join Date
    Mar 2003
    Posts
    191
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VB Script in Custom Form (2000/2002)

    Thanks for that. Changing the ByBal to ByVal solved the previous error message and now the script runs to completion. The only problem is that the text does not populate into the lable field as required. The following is the complete code. I have had a look line by line with no luck. Thanks heaps for your help.

    Bill

    Option Explicit

    Dim ComboBox2
    Dim Label15

    Sub Item_CustomPropertyChange(ByVal ChangeProperty)
    Select Case ChangeProperty
    Case "ComboBox2"
    If Item.UserProperties("ComboBox2")= "Oracle Beijing" then
    Item.UserProperties("Label15") = "Beijing Address"
    End If

    If Item.UserProperties("ComboBox2")= "Oracle Chengdu" then
    Item.UserProperties("Label15") = "Chengdu Address"
    End If

    If Item.UserProperties("ComboBox2")= "Oracle Guangzhou" then
    Item.UserProperties("Label15") = "Guangzhou Address"
    End If

    If Item.UserProperties("ComboBox2")= "Oracle Shanghai" then
    Item.UserProperties("Label15") = "Shanghai Address"
    End If

    If Item.UserProperties("ComboBox2")= "Oracle Shenzhen" then
    Item.UserProperties("Label15") = "Shenzhen Address"
    End If

    End Select
    End Sub

  8. #8
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: VB Script in Custom Form (2000/2002)

    Okay, this is fun. I just realized you have to pick Forms>Run Form to activate the code in the first place, at least in my test using a custom form not published to an Exchange server.

    Regarding the code, some notes:

    Option Explicit

    Dim ComboBox2 'These should not be declared variables, as they are controls on your form.
    Dim Label15

    Sub Item_CustomPropertyChange(ByVal ChangeProperty)
    Select Case ChangeProperty
    Case "ComboBox2" 'Use the field name, not the control name (Properties>Value tab)
    If Item.UserProperties("ComboBox2")= "Oracle Beijing" then
    Item.UserProperties("Label15") = "Beijing Address" 'Same as above
    End If
    If Item.UserProperties("ComboBox2")= "Oracle Chengdu" then 'Etc.
    Item.UserProperties("Label15") = "Chengdu Address"
    End If
    If Item.UserProperties("ComboBox2")= "Oracle Guangzhou" then
    Item.UserProperties("Label15") = "Guangzhou Address"
    End If
    If Item.UserProperties("ComboBox2")= "Oracle Shanghai" then
    Item.UserProperties("Label15") = "Shanghai Address"
    End If
    If Item.UserProperties("ComboBox2")= "Oracle Shenzhen" then
    Item.UserProperties("Label15") = "Shenzhen Address"
    End If
    End Select
    End Sub

  9. #9
    2 Star Lounger
    Join Date
    Mar 2003
    Posts
    191
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VB Script in Custom Form (2000/2002)

    Bingo that's it! How could I have missed that. Very embarrasing, I looked at it for ages. Thanks for your help.

    Bill

  10. #10
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: VB Script in Custom Form (2000/2002)

    I blame the lack of documentation, myself. <img src=/S/wink.gif border=0 alt=wink width=15 height=15>

  11. #11
    2 Star Lounger
    Join Date
    Mar 2003
    Posts
    191
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VB Script in Custom Form (2000/2002)

    jscher2000 - Actually looking at your graphic and code I am prompted to ask another question. How do I get the code to populate the full addresses (all but one of which I am yet to obtain) in the lable box. I used my initial explanation/s in the interest's of brevity.
    I hope my graphic adequately explains what I am trying to do. Thanks so much.

    Bill

  12. #12
    5 Star Lounger
    Join Date
    May 2001
    Location
    Washington, USA
    Posts
    750
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VB Script in Custom Form (2000/2002)

    Sorry about the ByBal typo. I'm my own worst enemy.

    You could fill the label box this way:

    If Item.UserProperties("ComboBox2")= "Oracle Shenzhen" then
    Item.UserProperties("Label15") = "Shenzhen Address" & vbcr & "address1" & vbcr & "address2" & vbcr & "city " & "state " & "zip"
    End If

Posting Permissions

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