Okay here is my code:

If optName.Value = True Then
Dim strSQL As String
strSQL = "SELECT * FROM Usages WHERE UsageID = " & List2.Text & ""
Adodc1.RecordSource = strSQL
Adodc1.Refresh

Refresh is causing an error in from clause??
I tried setting my adodc1 to an adcmdunknown recordsource, with no avail. i then get no recordsource specified error.

please help me with this, i am at my wits end. i have looked it up, i can't find the answer anywhere. the microsoft website has an explanation but i can't figure out how to solve it.

:(

Hi,

In your database table, if UsageID is Text/String, then you need to wrap the value with single quotes...
strSQL = "SELECT * FROM Usages WHERE UsageID = '" & List2.Text & "'"

Also check Database File (In case of access) is properly set..

Regards
Veena

'if your list2.text is a Number 
strSQL = "SELECT * FROM Usages WHERE UsageID = " & Cint(List2.Text) & ""

A String is a String...
A number is a Number..

it is a string, however List2.Text is a listbox.

Is is possible to query a table from a listbox?

would this require some sort of an array?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.