Filling Combo Box

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Reena83
    New Member
    • Sep 2006
    • 32

    Filling Combo Box

    Hi guys,
    Im having problems with my project. I can not seem to fill data from a database into a combo box. I have the code :

    Private Sub FillcboConditio n()
    Dim pstConditionSQL As String
    Dim prsCondition As New ADODB.Recordset

    pstConditionSQL = "Select ConditionCode, ConditionDesc " & _
    "from tblCondition "


    prsCondition.Op en pstConditionSQL , gcnLibrary, adOpenStatic & _
    adLockOptimisti c, adCmdText


    cboCondition.Cl ear


    Do While Not prsCondition.EO F

    cboCondition.Ad dItem prsCondition!Co nditionCode & " - " & _
    prsCondition!Co nditionDesc
    prsCondition.Mo veNext

    Loop

    cboCondition.Te xt = "Select..."


    End Sub


    But it just does not work. Also with my flexgrid it seems to put the data under different heading??

    I dont understand the error that pops up either. SO just confused!

    Thanks
  • PEB
    Recognized Expert Top Contributor
    • Aug 2006
    • 1418

    #2
    Hi,

    Are you sure that the fields ConditionCode, ConditionDesc aren't null? Have you created a proper connection?

    Put Stop in your code and verify the values in your recordset using immediate Window or visualizing somewhere else...

    Have a nice day

    :)

    Vladimir

    Originally posted by Reena83
    Hi guys,
    Im having problems with my project. I can not seem to fill data from a database into a combo box. I have the code :

    Private Sub FillcboConditio n()
    Dim pstConditionSQL As String
    Dim prsCondition As New ADODB.Recordset

    pstConditionSQL = "Select ConditionCode, ConditionDesc " & _
    "from tblCondition "


    prsCondition.Op en pstConditionSQL , gcnLibrary, adOpenStatic & _
    adLockOptimisti c, adCmdText


    cboCondition.Cl ear


    Do While Not prsCondition.EO F

    cboCondition.Ad dItem prsCondition!Co nditionCode & " - " & _
    prsCondition!Co nditionDesc
    prsCondition.Mo veNext

    Loop

    cboCondition.Te xt = "Select..."


    End Sub


    But it just does not work. Also with my flexgrid it seems to put the data under different heading??

    I dont understand the error that pops up either. SO just confused!

    Thanks

    Comment

    • jpezhil
      New Member
      • Sep 2006
      • 9

      #3
      Are you sure that the fields ConditionCode, ConditionDesc aren't null? Have you created a proper connection?

      What is the Propose of this Code(I don't Know This One)
      =============== =============== =
      cboCondition.Te xt = "Select..."
      =============== =============== ==

      if U Check Null Values In Do Loop
      -------------------------------------------------
      cboCondition.Ad dItem iif(isnull(prsC ondition!Condit ionCode),'',prs Condition!Condi tionCode) & "-" &_
      iif(isnull(prsC ondition!Condit ionDesc),'',prs Condition!Condi tionDesc)
      Thanking U (For Ur Reply)

      Comment

      Working...