Sorting and Searching (1 Viewer)

Status
Not open for further replies.

Oldsoftboss

AWF VIP
Local time
Tomorrow, 02:40
Joined
Oct 28, 2001
Messages
2,504
This example demonstrates a way to sort listbox columns in ascending and decending order, and how to programmatically narrow a search in any field of the list box.

Dave
 

Attachments

  • Searching and Sorting.zip
    50.5 KB · Views: 3,870
Last edited:

kentwood

Registered User.
Local time
Today, 11:40
Joined
Aug 18, 2003
Messages
51
This is very neat. Thanks for posting. I can see many uses for this.
 

ddrew

seasoned user
Local time
Today, 15:40
Joined
Jan 26, 2003
Messages
911
OldSoftBoss, ive been using your example posted hear and adapted it to suit my DB, is there a way that I can ajust the coloum widths in the list box. Ideally they need to be dynamic, i.e to auto adjust as information was displayed. Thanks!
 

Oldsoftboss

AWF VIP
Local time
Tomorrow, 02:40
Joined
Oct 28, 2001
Messages
2,504
Dynamically, not that I know of. But you can manage the listbox when dragging the edge of the form
 

Attachments

  • Searching and Sorting 2.zip
    49.8 KB · Views: 1,264

ddrew

seasoned user
Local time
Today, 15:40
Joined
Jan 26, 2003
Messages
911
Just to let you know that Ive been impementing parts of this into my own DB, personaaly I think its so much better than a subform. The sort function is excellent. Im still woring on the resizing function. Two questions though;

1. Can I create a report from the results? As I had it before with one query it wasnt a problem, now when I sort its using different queries.

2. How can I show how many records have been found in the search?

Thanks!
 

Oldsoftboss

AWF VIP
Local time
Tomorrow, 02:40
Joined
Oct 28, 2001
Messages
2,504
Yes to both accounts.

Base the report on the same record source as the listbox.

You can do a record count. Create a text box on your Form/Report, and as the control source put =Count(*)

Dave
 

ddrew

seasoned user
Local time
Today, 15:40
Joined
Jan 26, 2003
Messages
911
OK I understand the count function, but with the report I have one button to open a report, but because the list can be based on a number of different querries it dosent know which one to look at. i.e I can click on the lbls and reorder decending or ascending , so the list is now looking at a different query. How can I tell it which one?
 

Oldsoftboss

AWF VIP
Local time
Tomorrow, 02:40
Joined
Oct 28, 2001
Messages
2,504
Maybe declare a variable at the top of the forms code

Dim strQuery as String

then when a label is clicked, you can load the query to the variable.
strQuery = "yourQueryName"

Once you know this you may be able to do a dcount on the query.

Dave
 
M

mOs

Guest
Quick Question on this guys..I more than appreciate what you've done OSB however, I need a simple Search Form and I was wondering what files would I need to delete and which query would I edit to implement and alter this to my fashion...I have already stretched the Search box and moved it to my liking...I just need to remove the other files that aren't needed for a simple project..

Thanks in advance

Might I add that Im NOVICE with Access 2003..lol
 
M

mOs

Guest
Quick Question on this guys..I more than appreciate what you've done OSB however, I need a simple Search Form and I was wondering what files would I need to delete and which query would I edit to implement and alter this to my fashion...I have already stretched the Search box and moved it to my liking...I just need to remove the other files that aren't needed for a simple project..

Thanks in advance

Might I add that Im NOVICE with Access 2003..lol
 

wardster

Registered User.
Local time
Today, 15:40
Joined
May 25, 2006
Messages
34
Hi - the query you need to edit is: "qryCDNoAsc" that is the one used to populate the list box when the form first loads, the others are only used when you click on the labels to re-order the list.

Hi Have attached a cut down version you could have a look at - and also incorporated a few other ideas i have picked up from this site.

Ian
 

Attachments

  • Search Only.zip
    98.3 KB · Views: 934

wardster

Registered User.
Local time
Today, 15:40
Joined
May 25, 2006
Messages
34
sorry just spotted a mistake in the previous attachment - rectified in this one, time did not update on change.
 

Attachments

  • Search Only.zip
    88.9 KB · Views: 1,289

Bee

Registered User.
Local time
Today, 15:40
Joined
Aug 1, 2006
Messages
487
wardster said:
sorry just spotted a mistake in the previous attachment - rectified in this one, time did not update on change.
Hi Wardster,

I have tried to modify your example; however, I can't get the search function to work in my version. Does it only depend on the txtSearch_Change() procedure or is there any other code that I have missed.

Thanks in advance.
B
 

wardster

Registered User.
Local time
Today, 15:40
Joined
May 25, 2006
Messages
34
Hi B,

You need the code as mentioned above > txtSearch_Change()

in order for it to work correctly you need to have both or the text boxes [txtSearch] and [txtSearch2] on your form and named the same.

2nd Point to ensure is that in your query, your form is referenced by its name - i have called mine frmMain so the code is
Code:
Like "*" & [Forms]![frmMain]![txtSearch2] & "*"
If you have named your form differently you will need to modify the form name.

This then checks the form for [txtSearch2] and filters according to its value.

Regards - Ian
 

Bee

Registered User.
Local time
Today, 15:40
Joined
Aug 1, 2006
Messages
487
wardster said:
Hi B,

You need the code as mentioned above > txtSearch_Change()

in order for it to work correctly you need to have both or the text boxes [txtSearch] and [txtSearch2] on your form and named the same.

2nd Point to ensure is that in your query, your form is referenced by its name - i have called mine frmMain so the code is
Code:
Like "*" & [Forms]![frmMain]![txtSearch2] & "*"
If you have named your form differently you will need to modify the form name.

This then checks the form for [txtSearch2] and filters according to its value.

Regards - Ian
It's working perfectly now, thank you very much Ian.

B
 

Bee

Registered User.
Local time
Today, 15:40
Joined
Aug 1, 2006
Messages
487
I wanted to view different forms using the same list box. For example the user can select from a combo box what form they wanted to open. I am not sure how to do the 'Raw source type' bit.

I created a query for each form i want to run and then wrote an if Statment that runs a query depending on user's selection. How do you get Row souce type written in VB?

Thank you,
B
 

kerie

New member
Local time
Today, 08:40
Joined
Sep 9, 2006
Messages
9
thank you Oldsoftboss, this has been a real help, its just the kind of search i been trying to do ............................. but, and there had to be one lol, i cant get my links to work from within the search, is there anything you could suggest please?

many thanks
 

kerie

New member
Local time
Today, 08:40
Joined
Sep 9, 2006
Messages
9
sample search

thank you Oldsoftboss, this search is great, i been trying to get something like this to work for a while now, but ....................... and there always has to be one, there is one problem, the search is working perfect, however, i cannot use my links when they are in the search result box, is there a way around this please,

thanks
 

rhett7660

Still Learning....
Local time
Today, 08:40
Joined
Aug 25, 2005
Messages
371
Wardstar..

Do you have a version that doesn't have all the other stuff opening.... Just the forms/qry/tbl??

Thanks
R~
 

Grum

New member
Local time
Today, 17:40
Joined
Feb 15, 2005
Messages
3
txtSearch Colour on Focus

Well done Oldsoftboss, this is a great little tool. One question, how have you been able to change the colour of the text box txtSearch when it has the focus? I can't find any code for it! I'd like to give it a different colour - this would have numerous other uses!!

Thanks again for the tool!
 
Status
Not open for further replies.

Users who are viewing this thread

Top Bottom