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

Recordset SQL and wildcard? 1

Status
Not open for further replies.

solo7

Technical User
Mar 14, 2001
243
NO
Could someone run through my code (below) please and tell me how to make it work ??? It just reaches the EOF and reports no match. And YES one does exist !

Its meant to search the field Dte (date format) in the Table TblDteList (no primary key) and display the value that matches the criteria '01/07/*'
I've used this code succesfully before, but never with the WildCard *

[bold]
Dim Rs1 As New ADODB.Recordset
Dim SQLCode, StrResult As String
Dim cnn As ADODB.Connection

'start search

Set Rs1 = New ADODB.Recordset
Set cnn = CurrentProject.Connection

'build up the SQL code
'

SQLCode = "SELECT TblDteList.dte FROM TblDteList WHERE (((TblDteList.dte) Like '01/07/*'));"

Rs1.Open SQLCode, cnn

'try and assign a value to StrResult - if it can then the process continues
'as normal, OR it will error out at this point
'and go to the error handler

StrResult = Rs1!dte
[/bold]

Steady ... [thumbsup2]
 
Is the select to go against and Access database or an SQL Server database? The syntax for wildcard is different on each.

Access uses *
SQL Server uses %

Is this, TblDteList.dte, a date/time data type?
 
"SELECT TblDteList.dte FROM TblDteList WHERE(format(TblDteList.dte,"yyyy,mm") = "2001,07"
 
cmmrfrds
That works just the way it should. it's the % sign doing the asterisk's job which solved it.

Cheers !!!

Steady ... [thumbsup2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top