17. september 2001 - 10:30Der er
22 kommentarer og 1 løsning
Søgefunktion der viser alle hits
Hejsa. Min søgefunktion ser således ud. Den åbner formularen kunder, og viser de hits der svarer til de kriterier man indtaster i søgemenuen. Men kan man lave den om, således at den viser alle kunderne i databasen, men sorterer dem efter kriterierne? Fx. søger jeg på danfoss, og hittet dukker op, og så skal det være sådan at hvis jeg kører tilbage i recordsene kommer firmanavnet candis op, og kører jeg frem kommer firmaet egeriis. Dvs den viser alle poster sorteret efter navnet danfoss. Nuværende kode ser sådan ud:
Private Sub cmdSøge_Click() On Error GoTo Err_cmdSøge_Click
Dim stDocName As String Dim stLinkCriteria As String
stDocName = \"Kunder\" stLinkCriteria = \"1\"
If Not fldIsEmpty(Me.Søgefelt1) Then stLinkCriteria = stLinkCriteria & \" AND Navnet Like \'*\" & Me.Søgefelt1 & \"*\'\"
End If
If Not fldIsEmpty(Me.Søgefelt2) Then stLinkCriteria = stLinkCriteria & \" AND [Nace-1] Like \'*\" & Me.Søgefelt2 & \"*\'\"
End If
If Not fldIsEmpty(Me.Søgefelt3) Then stLinkCriteria = stLinkCriteria & \" AND [Nace-3] Like \'*\" & Me.Søgefelt3 & \"*\'\"
End If
If Not fldIsEmpty(Me.Søgefelt4) Then stLinkCriteria = stLinkCriteria & \" AND [Postnr og by] Like \'*\" & Me.Søgefelt4 & \"*\'\"
Brug af AI afslører de svagheder, virksomheder allerede har opbygget gennem års cloud-transformation, nye SaaS-løsninger og fragmenterede sikkerhedssystemer.
Der er ca. 5000 kunder i databasen. Den skal vise alle 5000 kunder hver gang man søger, sorteret efter alfabetet på kundenavnet: fx abe, ble, citron og derudaf. Søger jeg så på ble, viser den ble, men går jeg en tilbage viser den abe, og en frem viser den citron osv. Bare lige for at være sikker på mit problem fremstår klart
numsi> If you search after ble then only those with ble will be shown in the result form. In other words NOT all 5000 records are shown. The stLinkCriteria is actually th efilter property for the form. The filer can be switched on and off with me.filterOn = True or false. This will allow you to see the other records. You can sort the records either in a query which you use as the records source, or´you can use the order by property of the form.
hi terry, det skal være sådan så alle 5000 records vises på een gang, hvor søgning \'ble\' bare skal være det hit der vises, hvor man så herefter kan gå tilbage og se \'abe\' og frem og se \'citron\'.
Kan det gøres ved at skrive me.filterOn = false? Hvor skal det skrives henne i koden?
I would suggest that you add a toggle button to the form which shows the result. Then in the toggle buttons on click event add
Me.FilterOn = Me.tglFilter.Value
NOTE: The name of the toggle buttonis tglFilter
This will only show you all the records, you still have to sort them. As mentioned you can do this either by using a query as the record source, or setting the order by property.
Numsi> if you want to see all 5000 records why do you have a search routine?
Imagine all the records sort by company name, then a user seeks on the company name \'danfoss\', and danfoss shows in the sortet records, and allowing the user the scroll the records forward and backward.
First you need to ensure that the data in the result form is sorted by comapnay name. Then I would suggest that you add another button to your search form to open the result form with all records.
The on Click event should be changed to something like this
Dim stDocName As String Dim stLinkCriteria As String Dim stArgs as String
Indtil videre har man 10 søgemuligheder: man kan søge på nummer, navnet, postnr osv. Og her dukker resultatet op, specifikt kun for det man søger på.
I stedet skal det være sådan, at når jeg søger på fx. postnr, så bliver alle poster først sorteret efter postnr og herefter peger søgningen på det postnr jeg søgte efter. Alternativt hvis jeg søger på navnet, bliver alle poster først sorteret efter alle navnene i databasen, og herefter peger søgningen på det navn jeg søgte efter. Ved du hvordan man laver dette? Kunder kan ikke baseres på en forespørgsel som order by navnet, idet navnet ikke behøves at være det kriterie som der sorteres efter. Jeg håber du kan hjælpe selvom det er lidt indviklet.
Do you normally only search using one field? The code actually allows searching on multiple fields!
If its possible to search on more than one field then wouldntit by an idea to be able to choose which field to choose from in the result form. This way the user can decide how he wants to see the records.
No, it is also possible to search on multiple fields eg. søgefelt + søgefelt2 + søgefelt5.
Maybe, i\'m not quite sure what you mean.
Its because I have an old Concorde database, which has the ability to search on 10 different search criteria, and show all the records ordered by the the searchfield (eg. Navnet) and pointing at the result of the name searched.
I think there has been a problem with the server, some of your comments havent been getting through.
Numsi> I am sure I know what you want, but I want to make sure that we agree with each other!
Lets say you search on søgefelt + søgefelt2, which field do we sort on? It is logical if you only search on one field but on multiple search fields we would maybe want to select one or more fields for the ORDER BY.
Oh, yes I can know see that it is a problem, cause in the old Concorde database, you are only allowed to seek on field,and thereby only order by the field you seek.
It\'s only logical to order by one field in this situation.
So if I make 2 different search forms, one that can search on one or more fields and then show only the hits that matches. And then another form that can only search by one field at the time, but then show all records, ordered by the field and highlighting the match.
The second search form can then have 10 search-fields, but it is only allowed to type one criteria. So it would be something like the pseudo code I wrote above. What are the VBA for such a method? Hope you have time to help me.
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.