LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Wildcard Filtering on ADO Recordset

I am not an expert coder.. more of a copy cat

As an example I will just use 1 record tables.

I have a datatable with three fields. For ease I have just put in Excel (cell referance below)

D1 E1 F1
CSXX850 8505141 22971.92

and I have a mapping table with 2 fields

A1 B1
8??514* CP5140

I am using ADO to get a text file and read into a record set (datatable).

I am running into problems when filtering as it doesn't find the record using the wildcards above.

If I change mapping table to 850514* (Leaving last number off), it filters fine. I guess my question is if there another wildcard I need to be using instead of the question mark.

Code Below:

Global mrsData As ADODB.Recordset

Sub Wildcards2()

Dim i As Integer
Dim lsSymbol As String
Dim lsfilter As String

InitData

Call OpenRecordset(mrsData)

i = 1
lsSymbol = Trim(CStr(Sheets("Controls").Cells(i, 4).Value))

Do While Not lsSymbol = ""

mrsData.AddNew

mrsData!GLID = lsSymbol
mrsData!JDEAcct = Trim(CStr(Sheets("Controls").Cells(i, 5).Value))
mrsData!Amount = Trim(CStr(Sheets("Controls").Cells(i, 6).Value))

mrsData.Update

i = i + 1
lsSymbol = Trim(CStr(Sheets("Controls").Cells(i, 4).Value))

Loop

i = 1
lsSymbol = Trim(CStr(Sheets("Controls").Cells(i, 1).Value))

Do While Not lsSymbol = ""

lsfilter = "JDEAcct like '" & lsSymbol & "'"
mrsData.Filter = lsfilter

If mrsData.RecordCount 0 Then
mrsData!KLXAcct = Trim(CStr(Sheets("Controls").Cells(i, 2).Value))
End If

i = i + 1
lsSymbol = Trim(CStr(Sheets("Controls").Cells(i, 1).Value))

Loop

Call CloseRecordset(mrsData)

End Sub

Private Sub InitWildcards()
Set mrsWildcards = New ADODB.Recordset
mrsWildcards.CursorLocation = adUseClient
mrsWildcards.CursorType = adOpenDynamic
mrsWildcards.LockType = adLockOptimistic
With mrsWildcards
.Fields.Append "JDEAcct", adVarChar, 10
.Fields.Append "KLXAcct", adVarChar, 10
End With
End Sub

Private Sub InitData()
Set mrsData = New ADODB.Recordset
mrsData.CursorLocation = adUseClient
mrsData.CursorType = adOpenDynamic
mrsData.LockType = adLockOptimistic
With mrsData
.Fields.Append "GLID", adVarChar, 10
.Fields.Append "JDEAcct", adVarChar, 10
.Fields.Append "KLXAcct", adVarChar, 10
.Fields.Append "Amount", adDouble
End With
End Sub


Public Sub OpenRecordset(ByRef prs As ADODB.Recordset)
prs.Open
End Sub

Public Sub CloseRecordset(ByRef prs As ADODB.Recordset)
prs.Close
Set prs = Nothing
End Sub

Thanks.
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot use recordset twice with copy From recordset JasonC Excel Programming 1 February 3rd 10 11:53 PM
ADO Recordset Tim Excel Programming 0 March 9th 09 04:03 PM
trouble filtering a list. Why isn't column filtering? Pat Excel Worksheet Functions 1 July 18th 05 03:30 PM
Type recordset/recordset? FlaviusFlav[_9_] Excel Programming 4 May 24th 04 12:16 PM
Recordset Stephan Kassanke Excel Programming 0 September 10th 03 04:45 PM


All times are GMT +1. The time now is 06:07 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"