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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

combo box, selection, sql

Status
Not open for further replies.
Joined
Jun 21, 2013
Messages
1
I am creating a combo box with a button. In the below vba code, I am getting the string from the combo box. Then, I am trying to use SQL to the corresponding distro lists in the table (same row). This VBA code below is getting a Run-time error '438' Object doesn't support this property or method and it points to the SQL statment in the debugging screen. Any help is greatly appreciated.


Code:
Private Sub Command11_Click()
Dim cnn As ADODB.Connection
  Dim rs As ADODB.Recordset
  Dim SQL As String
  Dim vFld As Variant

string1 = Combo27.Value

SQL = "SELECT [" & DistributionLists & "]  as Fld" & _
" FROM " & DistroLists & " WHERE " & string1 & "=" & Application


  rs.Open SQL

  vFld = rs!Fld
  
  Set cnn = Nothing
  Set rs = Nothing
  


MsgBox (vFld)


End Sub
 
& Application
What exactly do you expect to happen here. You are calling the Application object without of property so of course you get the error.
 
Also you define a Connection object but never instantiate it, you try to open a recordset without a database object, you do not set the connection of the database object, ....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top