A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

search form without changes in my tabel



 
 
Thread Tools Display Modes
  #1  
Old February 18th, 2009, 06:18 PM posted to microsoft.public.access.forms
Kim1000
external usenet poster
 
Posts: 1
Default search form without changes in my tabel

Hi
I can't figure out, how to make a form that only searches data in a tabel. I
don't want any changes in the tabel. The form shall be able to look up all
data,but the searchresult must not be saved in my tabel.

I have triede everything i can :-) but cannot find a solution. Is it
possible at all.
I'll be very thankfully for a solution.

best regards.
Kim N

  #2  
Old February 18th, 2009, 09:29 PM posted to microsoft.public.access.forms
Danny J. Lesandrini
external usenet poster
 
Posts: 263
Default search form without changes in my tabel

Kim:

I'm just guessing here, but if your "search criteria" is being saved, you are
probably typing it into a bound column.

When we create a form that allows searching, we usually add a text box
control (or other type control) that is NOT bound to any table field. My form
might have fields like ...

FName LName Phone Address Title

These are all bound to the table and if you don't want them to be edited, you
can make them read-only in a couple different ways, but probably need to
set their Locked property to true.

Next, you add a text box that is NOT bound to the table. Name it txtNameFilter
Users may type whatever they want into this box and it's virtually thrown away
when the form is closed.

Finally, you add code to the AfterUpdate event of this box to change the form's
RecordSource property. If, for example, the form was based on tblPerson, the
after update event of txtNameFilter might look like this ...

Dim sRS as String
Dim sNameFilter as String

sNameFilter = Trim(Nz(Me!txtNameFilter, ""))

If sFilter = "" Then
sRS = "tblPerson"
Else
sRS = "SELECT * FROM tblPerson WHERE [FName] = '" & sNameFilter & "'"
End If

Me.RecordSource = sRs

Notice that where I inserted the filter criteria it's surrounded by single quotes.
If you do this with LName and the filter is O'Brian, that embedded quote will
give you trouble. In that case, you need to use the Replace function too ...

Replace(sNameFilter,"'","''")

Doubling the embedded single qoute solves the problem. This should get you
started, or at least help you know what to ask next.
--
Danny J. Lesandrini

www.amazecreations.com


"Kim1000" wrote in ...
Hi
I can't figure out, how to make a form that only searches data in a tabel. I
don't want any changes in the tabel. The form shall be able to look up all
data,but the searchresult must not be saved in my tabel.

I have triede everything i can :-) but cannot find a solution. Is it
possible at all.
I'll be very thankfully for a solution.

best regards.
Kim N



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 07:33 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.