473,385 Members | 1,901 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,385 software developers and data experts.

Searching Access by a Form with Textboxes and Display Results in Another SplitForm

10
Hi guys out there,
There is this database Iam creating, I have a table with 40 fields among which there are Date/time, Text, Number, Memo and Yes/No fields and I have created the form bound to that tabe. I have also created Unbound form (for searching purpose) which is similar in layout with the bound one; in this search form the user will fill-in the keywords in as many text boxes as he wish to narrow down the search. The search results are displayed in the bound form (in a splitform view).
I have tried number of vb source codes I gethered from various sources from the internet they work well with text fields and other but they do not work with MEMO fields. The search on the MEMO field just returns nothing.
If anyone out there has a solution to this problem I will appreciate the assistance to make this project work.
The algorithm is: the code searches only the textboxes filled and discards the empty ones this is done after the user presses the search button. (Note: the fiels bears the same name in database table and Search Form)
The sample code is as follows:

Dim strWhere As String 'The criteria string.
Dim lngLen As Long 'Length of the criteria string to append to.
Const conJetDate = "\#mm\/dd\/yyyy\#" 'The format expected for dates in a JET query string.
If Not IsNull(Me.txtCode) Then
strWhere = strWhere & "([txtRefCode] Like ""*" & Me.txtRefCode & """) AND "
End If
'The next code is for memo field (which fails to work)
If Not IsNull(Me.txtDescription) Then
strWhere = strWhere & "([txtDescription] Like ""*" & Me.txtDescription & """) AND "
End If
'Date field example next. It worked, but Iwasnt satisfied because I wanted the user to search for an exact date (which worked fine) or the operator and a date eg. > 2/27/2008 (which wont work with this code; suggestions requested.
If Not IsNull(Me.txtDateReported) Then
strWhere = strWhere & "([txtDateReported] = " & Format(Me.txtDateReported, conJetDate) & ") AND "
End If
'The code goes on for all 40 fields then finally:
'See if the string has more than 5 characters (a trailng " AND ") to remove.
lngLen = Len(strWhere) - 5
If lngLen <= 0 Then 'Where there was nothing in the string.
MsgBox "No criteria", vbOKOnly, "No Data Intered."
Else 'There is something there, so remove the " AND " at the end.
DoCmd.OpenForm "frmSearchResults"
DoCmd.Maximize
strWhere = Left$(strWhere, lngLen)
'Finally, apply the string as the form's Filter.
Forms!frmSearchResults.Filter = strWhere
Forms!frmSearchResults.FilterOn = True
End If


I came accross this code in the net and it was very helpful exept for the memo fields and date (which I need to use operators like >,< and <>.)

I am stuck here and desperate in need of resque. Anyone out there?
Thnx in advance
kmiraji@yahoo.com
Apr 18 '08 #1
0 1428

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

Similar topics

6
by: Michael Bulatovich | last post by:
I have a very simple db I use for keeping track of hours, tasks, projects, clients etc. It has a form that I use to enter data. Currently the form has a textbox for a field called "start time",...
6
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much...
3
by: Cillies | last post by:
Does anyknow how to control dates in acess 2000, the thing is I want to search for records using a form by date. I will be using a between date search box. But i want to enter say todays date but...
4
by: Megan | last post by:
Okay, I have a few questions regarding an Access database our company has. I should first mention that I'm not that knowledgable in Access and don't really know how to use it, but I am learning. We...
7
by: evilcowstare via AccessMonster.com | last post by:
Hi, I have searched the forum for answers on this and to be honest as a novice I find it a bit confusing so apologies if it is simple. There are some searches that I want to apply to my database....
7
by: john | last post by:
In my form I have a master table and a details table linked 1xM. I can search through the whole parent table but I also like to be able to search through the child table fields to find parent...
9
by: pic078 via AccessMonster.com | last post by:
I need serious help - I have a frontend/backend Access database (2 MDE Files) that remains stuck in task manager after exiting the application - you can't reopen database after exiting as a result...
0
by: cannonpm | last post by:
Greetings and salutations. I have developed an A2K3 MDB and have a search form modeled after Allen Browne's search form (http:// allenbrowne.com/ser-62.html). It works well except for records which...
1
by: OfficeDummy | last post by:
Hello, everyone! I have a search form with 12 checkboxes (= 12 months), and another form which displays the search results. On the display form, I'd love to display only the months that have been...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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.