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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|