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!

RUNTIME ERROR 2176 1

Status
Not open for further replies.

Aaswi

Programmer
Apr 25, 2008
2
Hi to every one in the Forum.
My name is ALi and am new to the Forum. I have a problem with Filter in VBA when i try to execute the following code

----------------------------------
If RS1.RecordCount > 0 Then
X = "("
Do While Not RS1.EOF
X = X + "'" + RS1.Fields(0) + "'"
'MsgBox X

RS1.MoveNext

If Not RS1.EOF Then
X = X + ","
Else
X = X + ")"
End If
Loop
' MsgBox X
X = "EMPLOYEES IN " + X

Me.Filter = X
Me.FilterOn = True
' MsgBox X
End If
--------------------------
 
It works for me, though the usual text concatenator is & not +, + can cause problems. What error are you getting?
 
Check out thread705-1465113.

You have probably exceeded the allowable length of the filter property.
 
A suggestion for next time you post is to include the message for the error. I think most of us have not memorized the error codes.

 
How are ya Aaswi . . .

. . . and this:
Code:
[blue]   If RS1.RecordCount > 0 Then
      Do Until RS1.EOF
         If x <> "" Then
            x = x & ", '" & RS1.Fields(0) & "'"
         Else
            x = "('" & RS1.Fields(0) & "'"
         End If
         
         RS1.MoveNext
      Loop
     
      x = "EMPLOYEES IN " & x & ")"
      
      Me.Filter = x
      Me.FilterOn = True
   End If[/blue]
[blue]Your Thoughts? . . .[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
Have you looked at the link posted by Golom?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top