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

Clearing Text/List boxes, display of SQL query statement

114 100+
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 boxes of data from form-1.

1) How do I cause the SQL command window not to show for that SQL command?

The query results is placed in a ListBox on Form-2 and desired rows in the list box are selected/clicked, followed by a click on a button that calls a VBA routine that extracts the bound column of the selected rows and calls a Report that prints the selected rows. When printing is finished the next thing that is called is Open Form-1 (returning to starting point).

What I need to do is clear the 3 text boxes on Form-1 and the list box on Form-2. Even when all 3 text boxes are changed (new data or cleared) the results that show after the query on Form-2 list box remain the same (does not change from the 1st used as to the list box). Can never seem to rest or clear these boxes.

2) How or where can I clear the Text Boxes and the List Box prior to their use on 2nd and subsequent uses? Would that be a properties setting or would I do this in the existing VBA code or new VBA code for an event?

Thanks
Dec 23 '06 #1
7 4490
MMcCarthy
14,534 Expert Mod 8TB
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 boxes of data from form-1.

1) How do I cause the SQL command window not to show for that SQL command?

The query results is placed in a ListBox on Form-2 and desired rows in the list box are selected/clicked, followed by a click on a button that calls a VBA routine that extracts the bound column of the selected rows and calls a Report that prints the selected rows. When printing is finished the next thing that is called is Open Form-1 (returning to starting point).

What I need to do is clear the 3 text boxes on Form-1 and the list box on Form-2. Even when all 3 text boxes are changed (new data or cleared) the results that show after the query on Form-2 list box remain the same (does not change from the 1st used as to the list box). Can never seem to rest or clear these boxes.

2) How or where can I clear the Text Boxes and the List Box prior to their use on 2nd and subsequent uses? Would that be a properties setting or would I do this in the existing VBA code or new VBA code for an event?

Thanks
1)
Close the query in the macro as soon as you've used it.
2)
Me.Refresh will reset the form.

Merry Christmas

Mary
Dec 25 '06 #2
ljungers
114 100+
Thanks for the reply and closing the query makes scense, but I am not sure where I should perform a close of that query, and how it should be done.

The Me.Refresh, is that to be placed in my VBA code. Do I use the form name with this refresh? I'm new to the VB coding and have had help with the code I'm using now.

Thanks
Dec 26 '06 #3
ljungers
114 100+
I tried the Me.Refresh in both places of my VBA (after the DoCmd.openreport and the "back to main form" button. Seams to clear and accept new input after cycling two time's (click the select button and then click back, then select) and you see the new selected data, but the text boxew still have the original sealected data.
Dec 27 '06 #4
ljungers
114 100+
I should clear up some possible confusion at this point. What I have is 2 forms, 1 report, 1 macro with a query and open form.

The 1st form Form-1, has 3 text boxes, 2 command buttons (Exit, Search).
1, 2 or 3 text boxes may be filled in or left blank. Clicking on the Exit button uses OnClick = ‘Event Procedure’ that performs a VBA “DoCmd.Quit”.
Clicking on the Search button uses OnClick = “Lukup_Macro” a macro, that 1st performs ‘OpenQuery’ called “LukupQuery” that uses the data in the Form-1 text boxes in a WHERE statement in a SELECT then 2nd performs ‘OpenForm’ named form-2.

Form-2 has 1 list box, 2 command buttons (Back to Lookup, Print Selected). List box is populated by the results of the query. 1 or multiple rows in the list box may be clicked/selected. The Print Selected button uses OnClick = ‘Event Procedure’ and performs a VBA PrintSelectedItems_Click that fetches selected info in the list box and performs a “DoCMD.OpenReport” that prints a report for each row selected, and returns to Form-1 when report is finished printing.

This all works great, the way it should work, BUT what I’m having a problem doing is:

Clearing out the text boxes on Form-1 when the button ‘Back to Lookup’ is clicked on (should they change there mind after looking at the results) so that new data may be entered for a new search.
Form-2 list box also needs to be cleared out as well. When returning back to Form-1 prior entered data remains and is displayed, and even if you change this information in these text boxes, clicking on Search the ListBox in Form-2 still displays the prior (1st results) from the query. This also happens when returning to Form-1 from printing the report on Form-2.

I need to clear/null out these text and list boxes so that a new search and selection can be done. I hope this clears up any confusion that may of arisen from my 1st post.

Thanks
Dec 27 '06 #5
ljungers
114 100+
I guess what I want to know is how to reference a text box on another form while I'm working with the current form in VBA. I want to move blanks/null to the fields that are on another form.
Dec 28 '06 #6
MMcCarthy
14,534 Expert Mod 8TB
I guess what I want to know is how to reference a text box on another form while I'm working with the current form in VBA. I want to move blanks/null to the fields that are on another form.
As long as the other form is open you can reference the texbox with:

Forms![FormName]![TextboxName]

Mary
Jan 1 '07 #7
MMcCarthy
14,534 Expert Mod 8TB
I should clear up some possible confusion at this point. What I have is 2 forms, 1 report, 1 macro with a query and open form.

The 1st form Form-1, has 3 text boxes, 2 command buttons (Exit, Search).
1, 2 or 3 text boxes may be filled in or left blank. Clicking on the Exit button uses OnClick = ‘Event Procedure’ that performs a VBA “DoCmd.Quit”.
Clicking on the Search button uses OnClick = “Lukup_Macro” a macro, that 1st performs ‘OpenQuery’ called “LukupQuery” that uses the data in the Form-1 text boxes in a WHERE statement in a SELECT then 2nd performs ‘OpenForm’ named form-2.

Form-2 has 1 list box, 2 command buttons (Back to Lookup, Print Selected). List box is populated by the results of the query. 1 or multiple rows in the list box may be clicked/selected. The Print Selected button uses OnClick = ‘Event Procedure’ and performs a VBA PrintSelectedItems_Click that fetches selected info in the list box and performs a “DoCMD.OpenReport” that prints a report for each row selected, and returns to Form-1 when report is finished printing.

This all works great, the way it should work, BUT what I’m having a problem doing is:

Clearing out the text boxes on Form-1 when the button ‘Back to Lookup’ is clicked on (should they change there mind after looking at the results) so that new data may be entered for a new search.
Form-2 list box also needs to be cleared out as well. When returning back to Form-1 prior entered data remains and is displayed, and even if you change this information in these text boxes, clicking on Search the ListBox in Form-2 still displays the prior (1st results) from the query. This also happens when returning to Form-1 from printing the report on Form-2.

I need to clear/null out these text and list boxes so that a new search and selection can be done. I hope this clears up any confusion that may of arisen from my 1st post.

Thanks
When back to lookup is clicked add this line to the code

Forms![Form-1_Name].Refresh
Jan 1 '07 #8

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

Similar topics

2
by: Jeff | last post by:
Hello All: What I am trying to do is bind a textbox (really several text boxes) based on a list box selection. Basically what I'm dealing with are two tables with a 1 to 1 relationship. I...
19
by: dmiller23462 | last post by:
Hi guys....I have absolutely NO IDEA what I'm doing with Javascript but my end result is I need two text boxes to stay hidden until a particular option is selected....I've cobbled together the...
1
by: Serious_Practitioner | last post by:
Hello, all - I want to get a customer name, address and so forth from a customer table using either a SELECT statement in a VBA procedure or in a query. The user should be able to put a customer...
0
by: starace | last post by:
I have designed a form that has 5 different list boxes where the selections within each are used as criteria in building a dynamic query. Some boxes are set for multiple selections but these list...
7
by: Mark | last post by:
Hi All, I have a report which is based on a query which is used to produce QC check sheets. I have quite a few text boxes which are used to display questions depending on the value of one...
10
by: lorirobn | last post by:
Hi, I have a form with several combo boxes, continuous form format, with record source a query off an Item Table. The fields are Category, Subcategory, and Color. I am displaying descriptions,...
12
by: ljungers | last post by:
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....
8
by: HowardChr | last post by:
Is there a way to code a command button on a form that will clear all "-1" Yes/No fields on a table to show as "0"? I tried to type in: "update "InputH- 1" Set Chooser = 0", but am getting an...
10
by: nickvans | last post by:
I have a form in which users may search for a module based on a number of criteria including three check boxes (indicating which processes have been completed) as well as a text box for the user to...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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...

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.