472,145 Members | 1,612 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Creating a Search Form in Access 2003

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
1 4729
debasisdas
8,127 Expert 4TB
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.

Similar topics

2 posts views Thread by Iain Miller | last post: by
1 post views Thread by John T Ingato | last post: by
reply views Thread by Saiars | last post: by

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.