Combo box question

Combo box question

Post by Joos » Sat, 22 Feb 2003 00:01:43



Hi,

Using VB6, I have a recordset containing a field that can contain either an
"A" or a "S". On the form, however, I want to display the meaning of  A and
B using a combobox.

Somehow I am really stuck here. Can anybody share an example of how to use
the combobox? I really don't have any luck Googling  :-(

BTW: I am not using a DBCombo here beacause there is no table conataining
the A an S choices and their description.

For what it is worth, here's the form_load sub

Private Sub Form_Load()
  Dim sSql As String

  Set adoPrimaryRS = New Recordset
  sSql = "SELECT * FROM Artikel " & _
         "WHERE ArtikelId=" & mArtikelId
  adoPrimaryRS.Open sSql, conBB, adOpenStatic, adLockOptimistic

  Set rsBrType = New Recordset

  Me!Combo1.AddItem "Artikelregel"
  Me!Combo1.AddItem "Specificatieregel"
  Me!Combo1.DataSource = adoPrimaryRS  '> causes error!

  Dim oText As TextBox
  'Bind the text boxes to the data provider
  For Each oText In Me.txtFields
    Set oText.DataSource = adoPrimaryRS
  Next

  Dim oCheck As CheckBox
  'Bind the check boxes to the data provider
  For Each oCheck In Me.chkFields
    Set oCheck.DataSource = adoPrimaryRS
  Next

  Screen.MousePointer = vbDefault

End Sub
TIA.

Joost.

 
 
 

Combo box question

Post by dnage » Sat, 22 Feb 2003 07:36:32


heres one way... as long as there are only two values....
    One CommandButton, one ComboBox...

Option Explicit

Private Sub Command1_Click()
Static s As String
    'simulate the database value
    If s <> "A" Then
        s = "A"
    Else
        s = "S"
    End If
    Command1.Caption = s

    'change the combobox
    Combo1.ListIndex = IIf(s = "A", 0, 1)

End Sub

Private Sub Form_Load()

Combo1.AddItem "Artikelregel"
Combo1.AddItem "Specificatieregel"

End Sub

D.

 
 
 

1. embarassing newbie combo box questions

Can anyone tell me how to populate a data control combo box with ALL the
instances of a field? Right now there is only one item in each box. I hope
that makes some sense. Also if this question has been asked a million
times before, could someone point me toward the FAQ. Thanks, James.

2. MS SQL Server 7.0, DbLib and Big Varchars

3. standard combo box question

4. Help: Multi-User Database Question...

5. VB Newbie: Combo Box Question

6. know the answer but they won't take no for an answer..

7. Combo Box Question

8. APEX

9. VB Combo Box question

10. Combo Box Question

11. 2 Combo Box Questions

12. combo box question

13. newbie DB Combo box question