By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,241 Members | 760 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,241 IT Pros & Developers. It's quick & easy.

Access 2000 OnChange Event ignores a space

P: 1
I am using MS Access 2000 on a Windows XP machine.

I have a list form, listing the number of companies a business is dealing with. I have a filter field on the form which is used to filter the list as characters are typed in the filter field, using the OnChange event for the field.

Generally the filter works fine except when a company name contains a space. The space seems to get ignored in the code for the OnChange event. Ihave checked the field length of the text entered and the last character. The space is there before the filter is performed. After the filter is completed the space seems to be dropped from the filter field. If another character is typed in the field it sits right behind the last character before the space. Therefore, the filter no longer works properly.

This is the code used in the OnChange event:

Me.Filter = "[Supplier Name] Like '" & SupplierFilter.text & "*'"
Me.FilterOn = True
Me!RecCount = Forms![frm Payables List].RecordsetClone.RecordCount
If Me!RecCount = 0 Then ' Checks for empty filter result
Exit Sub
SupplierFilter.SelStart = 10 ' Position to the last good character
End If

Any help that anyone could offer is much appreciated, even if only to confirm that a blank cannot be part of a filter.
Mar 14 '07 #1
Share this Question
Share on Google+
1 Reply

Expert Mod 10K+
P: 14,534
Try this ...
Expand|Select|Wrap|Line Numbers
  1. Me.Filter = "[Supplier Name] Like '" & Me!SupplierFilter.Value & "*'"
  2. Me.FilterOn = True
  3. Me!RecCount = Forms![frm Payables List].RecordsetClone.RecordCount
  4.     If Me!RecCount = 0 Then         ' Checks for empty filter result
  5.    Exit Sub
  6. Else
  7.    SupplierFilter.SelStart = 10  ' Position to the last good character
  8. End If
Mar 17 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.