populated combo box value by a SQL SELECT statement.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kirubagari
    New Member
    • Jun 2007
    • 158

    populated combo box value by a SQL SELECT statement.

    My form displays a combo box populated by a SQL SELECT statement. The user
    will select a row from the combo box. I then want the value in a field of the
    row selected in the combo box to be used as the selection criteria in a SQL.Attach is my code but incomplete..Dea r experts kindly help
    Code:
    Private Sub coReasonCode_Click()
    
        Dim Sreasoncode As String
        Dim sSQL As String
        Dim oSQL As clsSQL
        Dim cRow As FwAttributes
        Dim cRows As Collection
    
        Sreasoncode = coReasonCode.text
    
        sSQL = "select descs,user,brief_desc from cim_tbl_multiplehold" & _
                " where comment_code = Sreasoncode "
            
        Set oSQL = New clsSQL
        oSQL.Server = "CARdefault"
        
        oSQL.SqlCall = sSQL
        Set cRows = oSQL.SqlResult
    
    End Sub
    statement.
  • VijaySofist
    New Member
    • Jun 2007
    • 107

    #2
    Hi kirubagiri,

    In your code plz try the following changes.

    If the comment_code field is numeric use this
    Code:
    " where comment_code = " & Val(Sreasoncode)
    Or else the comment_code is text then use this below
    Code:
    " where comment_code = '" & Sreasoncode & "'"

    All the Best

    Regards
    Vijay.R

    Comment

    Working...