|
Is there a simple way to pass a parameter to an ADO recordset instead
of using a hard coded where statement like below(something like
forms!aaa!fieldname). I've done a fair bit of searching but can not
seem to come up with a way to provide this in a simple manner. I have
done this using pass through queries and stored procedures (as a form
based search method)but I guess I am just experimenting to see if the
below is a more efficient way to search large recordsets by passing
parameters from a form or am I just wasting my time
The db in question references both DAO ADO recordsets.
Public Function test4()
Dim cnn As ADODB.connection
Dim rst As ADODB.Recordset
Dim strSQL As String
Set cnn = New ADODB.connection
Set rst = New ADODB.Recordset
strSQL = "SELECT street, town, id, " & _
"telephoneid " & _
"FROM tble where street like 's%'"
cnn.Open "DSN=do;Description=do;APP=" & _
"Microsoft Office XP;WSID=;DATABASE=" & _
"do;Trusted_Connection=Yes"
rst.Open strSQL, cnn
Forms!aaa.RecordSource = strSQL
rst.Close
Set rst = Nothing
cnn.Close
Set cnn = Nothing
End Function
Thanks for any assistance
Phill |