473,387 Members | 1,463 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How do I create a filter in a form

Hi

I'm a complete newbie to Access but work have asked me to create a form on my database which will allow all users to search in a box in a split form, and relevant records appear in the lower screen. I'm working in Access 2007.

I have a text box at the moment for users to type their number into (document number, etc) with a macro button to search. The code for the button is:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command26_Click()
  2.     If IsNull(Text24) = False Then
  3.         Me.Recordset.FindFirst "[t0000_DRAWING_LIST]=" & Text24
  4.         Me!Text24 = Null
  5.         If Me.Recordset.NoMatch Then
  6.             MsgBox "No record found", vbOKOnly + vbInformation, "Sorry"
  7.             Me!Text24 = Null
  8.         End If
  9.     End If
  10. End Sub
My table is t0000_DRAWING_LIST and the command button is Text24.

At the moment when I click the button it shows up with "No records found" and I'm not sure why.

Lots of people are going to be using this for searching so I want it to be as user friendly as possible.

Can anyone help me with this please? I apologise if I have left anything out.

Thanks in advance,

Helen.
Nov 4 '13 #1
3 1280
NeoPa
32,556 Expert Mod 16PB
Helen,

Your code is not filtering the data, but is simply trying to move to the first matching record.

It won't do that as the specification is not correctly formed. You need to specify which field the data you're searching for matches and not the table name itself.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command26_Click()
  2.     With Me
  3.         If IsNull(.Text24) Then
  4.             .FilterOn = False
  5.             Exit Sub
  6.         End If
  7.         .Filter = Replace("[FieldName]=%N", "%N", Nz(.Text24, ""))
  8.         .FilterOn = True
  9.     End With
  10. End Sub
You need to change where it says [FieldName] to match your own. The message is probably superfluous as when they see there are no records it will be fairly clear nothing was found.
Nov 4 '13 #2
Hi
I've entered what you've shown above and it comes up with a parameter box which asks me to re-enter each part of the number.

The type of number i'm searching is actually a series of numbers and letters with dashes, eg XXX-YYY-ZZZ. The parameter box then shows "enter parameter value XXX" then "enter parameter value YYY" etc. Final after I've clicked through the boxes, an error message comes up saying that my parameters are too complex to be evaluated.

Any suggestions?
Nov 4 '13 #3
NeoPa
32,556 Expert Mod 16PB
Any suggestions?
The filter code will need to change of course, as the number isn't a number, but a string. Replace line #7 with :
Expand|Select|Wrap|Line Numbers
  1.         .Filter = Replace("[FieldName]='%N'", "%N", Nz(.Text24, ""))
That should sort it if I'm not mistaken. For more on this see Quotes (') and Double-Quotes (") - Where and When to use them
Nov 5 '13 #4

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

Similar topics

6
by: skgolden | last post by:
My husband and I own a small temporary labor company and deal with 4 major clients (A,B,C & D), each of which has about 2 dozen units in our tristate area that we deal with (ie, Company A, units...
4
by: Jigar Patel | last post by:
Hello, I want to create Nonrectengular form in VB.NET. Just like Windows Media Player Skins. Not Round,RoundRectengal etc.... Mean i have one Bmp and i want to create some picture portion on...
4
by: Steven | last post by:
Hi, I have a database table field to store the form name, I want to create the particular windows form by using the value that read from that DB field. For examples, the table field has a value...
3
by: kpuchala | last post by:
Hello I'm beginnig to create my first application in Visual Web Debeloper 2005 Express. I need to create a web site (simple application), which will allow to list objects (records) stored in...
1
by: Ronniesss1 | last post by:
I have a table called RescheduleIns and another called Shop Complete Table that are opened together on another form called fAll Shop Orders. On this form, all the Shop Complete Table data is...
8
by: Paul H | last post by:
I want to base a form on a crosstab query. The query shows statistics for a user defined period. The column headings will look something like this: ClientID Month01 Month02 Month03 etc.. ...
0
by: Darionas | last post by:
Hi Somebody can help me? I made form. On form header there are two text boxes and command button. On form detail there is subform based on query. I want to filter by date (for exp.: from...
15
by: jt196 | last post by:
I'm trying to create an editable form of fulfilled orders on my system and am running into problems with creating a form based on this query. The field that I need to update (invoice number) is...
1
by: Mayan F | last post by:
If you're into that maybe you could help me with another thing I'm upto now: I succeeded in dynamically creating the controls but now I'm trying to dynamically create a form for these controls(to...
5
by: SValencia | last post by:
Hello my name is Steve and I am a newbie....almost. I have been working at learning html, graphics and css in my spare time. I have a site at www.ContractorInsurance.net. Yes, I am an...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.