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

Clearing Text/List boxes for new search

114 100+
I'm on the home streach of my project and found that my "Reset for New Search" command button not working as desired. What should happen is that when the button is clicked a Event Procedure is run. That event procedure should clear the text boxes that are used for a search query that loads the results into a list box on that same form.

When clicked, all is cleared in the text boxes, and the list box is cleared but shows column seperator lines in 1st row only . After entering new search data (let's say box 2 of the 3 boxes, and the search data is on the table) the "Search" button is clicked, the list box clears completely and nothing showing.

What I discovered is if I enter something in all 3 text boxes (say x, x, x) and click "Search" nothing happens, and then go back and delete 1st box, enter valid data in 2nd, delete 3rd and click the "Search" button again, the list box get populated like it should of after clearning the 1st search.

I can change any of the text box values and click "Search" not using the clear button, and that works loading new rows in that list box. Just the clear before a new search has problems.

Here is the code for the clear button click:

Private Sub clearButton_Click()
On Error GoTo Err_clearButton_Click
' clear the 3 text boxes, list box so that another search/query can be done
Me.WhatLastName.Value = ""
Me.WhatFirstName.Value = ""
Me.WhatMedRecNo.Value = ""
Me.SelectPrintItems.RowSource = ""
Me.Refresh

Exit_clearButton_Click:
Exit Sub

and here is the code for the search button click:

Private Sub SearchQuery_Click()
On Error GoTo Err_SearchQuery_Click

'Error checking to make sure user entered values for Last Name and First Name.
If Nz(Me.WhatLastName, "") & _
Nz(Me.WhatFirstName, "") & _
Nz(Me.WhatMedRecNo, "") = "" Then
MsgBox ("Please enter a Search value, all 3 may not be blank")
GoTo Exit_SearchQuery_Click
Else
Me.SelectPrintItems.RowSource = "Lukup_Query"
Me.SelectPrintItems.Requery

End If
Exit_SearchQuery_Click:
Exit Sub

The Lukup_Query is just a Select using the What... fields above in a WHERE statement to select for populating the list box.

Should work but I must be overlooking something that is obvious
Jan 1 '07 #1
12 9696
MMcCarthy
14,534 Expert Mod 8TB
Expand|Select|Wrap|Line Numbers
  1. 'Me.SelectPrintItems.RowSource = ""
Comment out this line and see what happens
Jan 1 '07 #2
ljungers
114 100+
Expand|Select|Wrap|Line Numbers
  1. 'Me.SelectPrintItems.RowSource = ""
Comment out this line and see what happens
When commented out all text & list box get cleared (no col seperators) but functionality still remains the same.
Jan 1 '07 #3
MMcCarthy
14,534 Expert Mod 8TB
When commented out all text & list box get cleared (no col seperators) but functionality still remains the same.
Try doing the same with the text boxes just leaving Me.Refresh
Jan 1 '07 #4
ljungers
114 100+
Try doing the same with the text boxes just leaving Me.Refresh
When all are commented out the Clear does nothing, but the Search works every time with any changes to any of the text boxes.
Jan 1 '07 #5
MMcCarthy
14,534 Expert Mod 8TB
When all are commented out the Clear does nothing, but the Search works every time with any changes to any of the text boxes.
Expand|Select|Wrap|Line Numbers
  1.      Me.WhatLastName = Null
  2.     Me.WhatFirstName = Null
  3.     Me.WhatMedRecNo = Null
Try this instead for the text boxes.

BTW are the textboxes bound to controls. If not the refresh should have worked.

Mary
Jan 1 '07 #6
ljungers
114 100+
Expand|Select|Wrap|Line Numbers
  1.      Me.WhatLastName = Null
  2.     Me.WhatFirstName = Null
  3.     Me.WhatMedRecNo = Null
Try this instead for the text boxes.

BTW are the textboxes bound to controls. If not the refresh should have worked.

Mary
that seems to work ok, just when the form open 1st time and when the Clear button is clicked the entire table is listed in the list box (29230 records). In design mode the text boxes and list box all show Unbound
Jan 1 '07 #7
MMcCarthy
14,534 Expert Mod 8TB
that seems to work ok, just when the form open 1st time and when the Clear button is clicked the entire table is listed in the list box (29230 records). In design mode the text boxes and list box all show Unbound
Try setting the listbox RowSource to "" again while leaving the textboxes set to null.
Jan 1 '07 #8
ljungers
114 100+
Try setting the listbox RowSource to "" again while leaving the textboxes set to null.
That seems to work as to clearing text boxes, and the list box, except the column dividers for the 1st row show, but can live with that.

The search works OK now and the only thing is that the list box loads the entire table when the form is first opened.
Jan 1 '07 #9
MMcCarthy
14,534 Expert Mod 8TB
That seems to work as to clearing text boxes, and the list box, except the column dividers for the 1st row show, but can live with that.

The search works OK now and the only thing is that the list box loads the entire table when the form is first opened.
Call the clear button event in the On load event of the form

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2.  
  3.    clearButton_Click
  4.  
  5. End Sub
Mary
Jan 2 '07 #10
ljungers
114 100+
Call the clear button event in the On load event of the form

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2.  
  3.    clearButton_Click
  4.  
  5. End Sub
Mary
Thanks Mary that worked. I think the list box is loading but being cleared after. The reason I say this is the time it takes for the form to open.
Jan 2 '07 #11
MMcCarthy
14,534 Expert Mod 8TB
Thanks Mary that worked. I think the list box is loading but being cleared after. The reason I say this is the time it takes for the form to open.
The other option is to put it in the on close event of the form.
Jan 2 '07 #12
ljungers
114 100+
Thanks to all of you that have helped me even on a holiday. It works the way I wanted it to function.
Jan 2 '07 #13

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

Similar topics

2
by: Savvas | last post by:
Hi everybody, I have a lot of textboxes on my form and a "Clear" button. Is there a way with a for loop or something to clear the textboxes, instead of writing textboxName.clear? Thanks a lot
3
by: Alex Wisnoski | last post by:
I have an edit record form with several text boxes, combo boxes, and check boxes. All of them are bound except for one combo box (cboPositionData), which I use to search for a specific record. I...
2
by: Jack Smith | last post by:
My development environment is ASP.Net with Vb.Net and Java script with .Net Framework 1.1 and IE 6.x. I have a search window and once the user done with search, if user wants to clear the search...
5
by: Drew Leon | last post by:
I have a Form with a Tab Control on it. Each of the Tabs have two List Boxes on them. When you Select an Item from the List Box, the Text Box at the bottom of the Form gets populated. I would like...
7
by: ljungers | last post by:
Have Form-1 with 3 text boxes and 1 command button. With any of the 3 boxes filled out and button is clicked, a Macro is performed that Opens a Query that has a WHERE clause that uses the 3 test...
7
by: Tim Hitchcock | last post by:
I have written a couple of programs in C# using Visual Studio.NET 2003. Both of these programs have the problem that when they are ran on my Windows XP computer at work items in list boxes and text...
6
by: woodey2002 | last post by:
Hi Everyone. Thanks for your time. I am trying to create a search form that will allow users to select criteria from multiple multi select boxes. So far i have managed to achieve a search option...
8
by: hollinshead | last post by:
Hi there i have bit of an issue. i haver this database that is purely used for searching records under certain criteria. This criteria is chosen by the user on a form using list boxes and combo...
2
by: hollinshead | last post by:
hi there, i have been having this issue for quite some time now and i cant seem to get my head around it. I am trying to create a database for candidates CV's and covering letters. basically the data...
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
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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.