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

rst.Filter Will Not Accept Non-Numeric (Help?)

Status
Not open for further replies.

PSUIVERSON

Technical User
Nov 6, 2002
95
US
I need to take a large table and based on one of the fields DEPT - I am filtering and then outputting to a .txt file. Right now I have roughly 35 departments. All BUT ONE are numeric department numbers. The final one is "L10". When I run this all of the departments are written to until it hits "L10" in which case I receive an error message

"RUN TIME ERROR 3001 - Arguments are of the wrong type, out of acceptable range or are in conflict with one another."

It always stops on "L10" so I am assuming that because of the "L" I am getting thrown here. But it's not a type mismatch error so I am confused. Does the filter method not accept non-numeric values?

Anyone experience this before? Thanks...

FYI - Here is the code [Note: rst2 is simply a table with one field that contains all the DEPT Numbers I am filtering]

...

rst.MoveFirst
rst2.MoveFirst

Do While Not rst2.EOF
DEPTNO = rst2.Fields(0)
rst.Filter = "CDEPT=" & DEPTNO
Do While Not rst.EOF
'Simply change to the F: Drive when needed for SOM
Open "c:\download\Dept_TEST\" & DEPTNO & "\PDPTMAST.txt" For Append As #1
i = 0
For Each fld In rst.Fields
If IsNull(rst.Fields(i)) Then
rst.Fields(i) = " "
End If
fldValue(i) = rst.Fields(i)
Write #1, fldValue(i),
i = i + 1
Next
rst.MoveNext
Write #1, "NULL"
Close #1
Loop
rst2.MoveNext
Loop

...
 
Thanks. I finally figured that out as well. However I am a little confused. The field I am filtering by is a TEXT field and I am wondering why the FILTER would work on the numeric values without single quotes if it's a text field shouldn't they be looked at as strings? Strange...But thanks...
 
When you don't have the quotes, Access parses the string as numeric if it can, hence it still worked before UNTIL you got to your alphanumeric value. Access couldn't parse this as a number and so threw an error. [pc2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top