CT Witter
MrExcel MVP
- Joined
- Jul 7, 2002
- Messages
- 1,212
I'm creating an unbound form and want to populate the form with data.
The code:
strSQLView ="SELECT * FROM tblHeader WHERE (LastName = 'PROFESSIONAL') "
works correctly and 131 Records are returned
However,
strSQLView ="SELECT * FROM tblHeader WHERE (LastName Like 'PROF*') "
fails and 0 Records returned
This statement SELECT * FROM tblHeader WHERE (LastName Like 'PROF*') works fine when placed into a query
Any suggestions?
Thanks,
CT
The code:
Code:
Private WithEvents mrst As ADODB.Recordset
Private Sub Form_Load()
On Error GoTo Form_Load_Error
Set mrst = New ADODB.Recordset
mrst.ActiveConnection = strConnectionString
mrst.Source = strSQLView
mrst.CursorType = adOpenStatic
mrst.LockType = adLockBatchOptimistic
mrst.CursorLocation = adUseClient
mrst.Open Options:=adAsyncFetch
On Error GoTo 0
Exit Sub
Form_Load_Error:
Call ErrorLog("Form_frmView", "Form_Load", "VBA Document", Erl, _
Err.Number, Err.Description)
End Sub
strSQLView ="SELECT * FROM tblHeader WHERE (LastName = 'PROFESSIONAL') "
works correctly and 131 Records are returned
However,
strSQLView ="SELECT * FROM tblHeader WHERE (LastName Like 'PROF*') "
fails and 0 Records returned
This statement SELECT * FROM tblHeader WHERE (LastName Like 'PROF*') works fine when placed into a query
Any suggestions?
Thanks,
CT