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

Creating a Search Form in Access 2003

P: 2
Hi there,

Can anybody help me and provide me with a SIMPLE solution to create a search form in Access 2003.

I have created a database for Finance Payments and want to enable the user to search on a number of different fields and to return records that meet the criteria in a subform below.

I'm testing this at the moment. So far i have:

3 unbound text boxes (to input the search parameters)

* TxtName (Name of Payee)
* TxtDate2 (Date)
* TxtInvoice (Invoice Number)

A sub form (frm_subformsearch) based on a query (qry_searchform) which gives me a list of all the records.

I'm basically stuck on the coding for selecting where the text boxes meet the criteria and returning these in the sub form.

I have downloaded a code from a website but it's not working - Can you tell me where i'm going wrong. Please note the code below is as was downloaded - i've not posted what i tried to do to tailor it to my database

Private Function BuildFilter() As Variant
Dim varWhere As Variant
Dim varColor As Variant
Dim varItem As Variant
Dim intIndex As Integer

varWhere = Null ' Main filter
varColor = Null ' Subfilter used for colors

' Check for LIKE First Name
If Me.txtFirstName > "" Then
varWhere = varWhere & "[FirstName] LIKE """ & Me.txtFirstName & "*"" AND "
End If

' Check for LIKE Last Name
If Me.txtLastName > "" Then
varWhere = varWhere & "[LastName] LIKE """ & Me.txtLastName & "*"" AND "
End If

Please help!

Thank you,

Nia x
Dec 17 '08 #1
Share this Question
Share on Google+
1 Reply

Expert 5K+
P: 8,127
Why are you using > to compare string.
Need to use Length function instead.
Dec 18 '08 #2

Post your reply

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