Author Topic: How to select a value from a drop down list through code.  (Read 5390 times)

Offline svakula

  • Jr. Member
  • **
  • Posts: 13
  • Karma: +0/-0
    • View Profile
How to select a value from a drop down list through code.
« on: April 30, 2006, 04:34:53 AM »
I have a form with a drop down list with few values in it. I want the first value from the drop down list to be selected when i trigger a specific event(e.g Button Click or drop down list click(not the drop down list in question)).

This can easily be done in VB, through Combo1.listindex = 1; Is it possible in Pivotal Active Access to code like that, otherwise what is the alternative to make a value in the drop down selected?

Offline Weng Keat Tan

  • Newbie
  • *
  • Posts: 5
  • Karma: +0/-0
  • Gender: Male
    • View Profile
Re: How to select a value from a drop down list through code.
« Reply #1 on: May 02, 2006, 01:51:26 AM »
You can attach a event hook script that triggers the following method:

Sub SetInitialValue( ByVal valIndex As Long, ByVal valText As String )

The above method belongs to the RComboSelect object.

e.g. UIMaster.RUICenter.GetCombo("Segment_Name", "Field_Name").SetInitialValue(1, "FirstValueOfCombo")


Offline Azzi

  • Newbie
  • *
  • Posts: 1
  • Karma: +0/-0
    • View Profile
Re: How to select a value from a drop down list through code.
« Reply #2 on: May 02, 2006, 01:52:56 AM »
You can attach client script to all controls of Active form using different events, for example you can add a new button on the from and attach  a client script to this button using  OnClick event. It is possible to modify all fields on the form including your drop down value from this script.

Offline svakula

  • Jr. Member
  • **
  • Posts: 13
  • Karma: +0/-0
    • View Profile
Re: How to select a value from a drop down list through code.
« Reply #3 on: May 06, 2006, 01:32:53 AM »
Thanks for ur reply, i tried with the following

But it is not working, it shows a message 'The specified segment can not be found' even if i give everything correct. I checked many times with all the combos on the screen, but still the same message.

I tried the 3 following statements, but none is working

UIMaster.RUICenter.GetCombo("Communication","Person_To_Contact").SetInitialValue 1, "Ciaran Kenny"
UIMaster.RUICenter.GetCombo("Communication","Person_To_Contact").IndexValue = 1
MsgBox UIMaster.RUICenter.GetCombo("Received From","Airline_ID").Value

Any idea what is going wrong ??? :(

Offline pivotalman

  • Jr. Member
  • **
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Re: How to select a value from a drop down list through code.
« Reply #4 on: May 06, 2006, 05:55:29 AM »
Did you try to specify an ordinal instead of segment name ?

Offline svakula

  • Jr. Member
  • **
  • Posts: 13
  • Karma: +0/-0
    • View Profile
Re: How to select a value from a drop down list through code.
« Reply #5 on: May 06, 2006, 10:29:36 PM »
Did you try to specify an ordinal instead of segment name ?

I tried, but this time it is showing, 'specified field not found'. I feel there is problem with the GetCombo() method itself. Because i tried all possible ways but in vain.

Need more help on GetCombo() method.


Offline slawomik

  • Newbie
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: How to select a value from a drop down list through code.
« Reply #6 on: May 11, 2006, 10:15:43 AM »
What type is the Person_To_Contact field?
If this is foreign key field (i.e. holding the id to other table record) you should not use Combo.
The right interface to use in such case is: IRRecordSelect.

Please let me know if this is the case.

Offline svakula

  • Jr. Member
  • **
  • Posts: 13
  • Karma: +0/-0
    • View Profile
Re: How to select a value from a drop down list through code.
« Reply #7 on: May 13, 2006, 12:12:07 AM »
What type is the Person_To_Contact field?
If this is foreign key field (i.e. holding the id to other table record) you should not use Combo.
The right interface to use in such case is: IRRecordSelect.

Please let me know if this is the case.


Yes, It is a foreign key field, so now i changed the method to GetForeignField(). Even then i could not make the first value selected automatically on load(or by hooking to an event - i tried both). I tried using the property IdValue.

Offline Weng Keat Tan

  • Newbie
  • *
  • Posts: 5
  • Karma: +0/-0
  • Gender: Male
    • View Profile
Re: How to select a value from a drop down list through code.
« Reply #8 on: May 23, 2006, 11:15:26 PM »
Try the following,

'To get the record Id of Ciaran Kenny, assuming that Person_To_Contact field is referenced to Contact table
With UIMaster.RSysClient     
        vntPersonToContact = .SQLSearch(.GetTable("Contact").Fields("Contact_Id").FieldId, "Ciaran Kenny", .GetTable("Contact").Fields("Full_Name").FieldId)
End With

UIMaster.RUICenter.GetForeignField("Communication","Person_To_Contact").SetInitialValue vntPersonToContact, "Ciaran Kenny"

'OR If the active form has more than one tab

UIMaster.RUICenter.GetForeignFieldEx("TabName","Communication","Person_To_Contact").SetInitialValue vntPersonToContact, "Ciaran Kenny"