Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
Ahmed  
#1 Posted : Friday, November 8, 2019 12:22:58 PM(UTC)
Ahmed

Rank: Newbie

Groups: Registered
Joined: 8/22/2019(UTC)
Posts: 9

Thanks: 2 times
Was thanked: 1 time(s) in 1 post(s)
Just wondering how the key of a Combo item can be returned. For instance:

Code:
    With Me.iGrid1

                .Combos.Add("MyKey")
                .AddItem "Item1"
                .AddItem "Item2"
    End With

I intend to add Combo "MyKey" to iGrid1, if it doesn't exist.
thanks 1 user thanked Ahmed for this useful post.
Igor/10Tec on 11/8/2019(UTC)
Igor/10Tec  
#2 Posted : Friday, November 8, 2019 5:06:01 PM(UTC)
Igor/10Tec

Rank: Administration

Groups: Administrators, Forum Moderator
Joined: 1/17/2011(UTC)
Posts: 1,111

Thanks: 15 times
Was thanked: 141 time(s) in 141 post(s)
Issue 'On Error Resume Next' and try to retrieve the Combo object using the iGrid.Combos("...") call. If it doesn't exist, an error occurs.

Here is a handy function implementing this idea:

Code:
Private Function ComboExists(ByVal psComboKey As String) As Boolean
   Dim oCombo As ComboObject
   On Error Resume Next
   Set oCombo = iGrid1.Combos(psComboKey)
   ComboExists = (Err.Number = 0)
End Function
thanks 1 user thanked Igor/10Tec for this useful post.
Ahmed on 11/8/2019(UTC)
Ahmed  
#3 Posted : Monday, November 11, 2019 11:30:49 AM(UTC)
Ahmed

Rank: Newbie

Groups: Registered
Joined: 8/22/2019(UTC)
Posts: 9

Thanks: 2 times
Was thanked: 1 time(s) in 1 post(s)
Thanks Igor.
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.