Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to use a combo box to get data from SQL? 1

Status
Not open for further replies.

Niki_S

Programmer
Jun 4, 2021
232
LK
I have a combo box as Combo1 and I want to get data from sql by using this combo box selected value. For that I did my code inside the click event in my combo box. But it is not ok and it says "method or data member not found".
This is my code,

Code:
Private Sub Combo1_Click()
    Dim sqlqueryVw As String
    Dim LNLOAD As ADODB.Recordset
    
  
    sqlqueryVw = "select dbo.FRI_MASTER_LineLoading.cLine,dbo.FRI_MASTER_LineLoading.dProdutionStart,dbo.FRI_MASTER_LineLoading.dProductionEnd," _
            & " dbo.OPS_MASTER_Style.cStyleNumber,dbo.OPS_REF_GarmentType.cGarmentCode" _
            & " FROM dbo.FRI_MASTER_LineLoading inner join  " _
            & " dbo.OPS_MASTER_Style on  dbo.FRI_MASTER_LineLoading.nStyleCode=dbo.OPS_MASTER_Style.nStyleCode inner join " _
            & " dbo.OPS_REF_GarmentType on dbo.OPS_MASTER_Style.nGarmentTypeID=dbo.OPS_REF_GarmentType.nGarmentTypeID" _
            & " WHERE dEntryDate BETWEEN CONVERT(DATETIME, '" & DTFrom.Value & "', 102) AND CONVERT(DATETIME, '" & DTTo.Value & "', 102) " _
            & " AND cFty='" & Combo1.Value & "'"


        Set LNLOAD = New ADODB.Recordset
        LNLOAD.CursorLocation = adUseClient
        LNLOAD.Open sqlqueryVw, cn, adOpenStatic, adLockReadOnly
        
End Sub

How can I fix this and how to use combo box to get data from sql?

Thank you
 
Did you try:

Code:
sqlqueryVw = "select dbo.FRI_ ...
...
& " AND cFty='" & Combo1.[blue]Text[/blue] & "'"
[ponder]

---- Andy

"Hmm...they have the internet on computers now"--Homer Simpson
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top