473,386 Members | 1,602 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.

Basic search form

Hello, I successully adapted a search form from a microsoft example into my own db.

MS Example

I type search parameters in 2 boxes and the results are returned in a new, basic query window.

I created:
2 text boxes
1 Command button ( search )
1 Macro to open the query
1 query

All works fine but there are 2 problems I can't resolve.

1) The users can mis-type the parameters and think there are no records. So I need to create a pull down list possibly combo box.
2) The results are returned in a plain query table. I need to direct them into a subform.

I tried many things; linking the texboxes to table/fields, raw data, expression building as well as using a combo box. I also changed the query's criteria to reflect the combo box.
Nothing works. It acts like the combo box isn't there at all.

I created a subform but I don't know how to send the resuls in it.
I also got the following suggestion which I don't understand.
"In the After Update event of either or both combo boxes, requery the subform. "
How do I "requery a subform" ?
Any suggestion? When giving details please keep in mind I'm very new at this .
Thanks!
Apr 20 '07 #1
3 1808
Corster
36
For your combo box, you'll need to set the following properties:

Expand|Select|Wrap|Line Numbers
  1. Private Sub cbxControlName_Click()
  2.     cbxControlName.RowSource = "SELECT DISTINCT Table.Column FROM Table ORDER BY Table.Column"
  3. End Sub
As for requerying a subform, try:
Expand|Select|Wrap|Line Numbers
  1. Me.SubFormName.Requery
Depending on which point you wish to requery, you will have to place your code in the control's Sub that you're changing to force the requery. If it's upon navigating records, you will have to put it in your Form_Current Subroutine.

As for the other part, I'm afraid I will not be able to assist...
Apr 20 '07 #2
For your combo box, you'll need to set the following properties:

Expand|Select|Wrap|Line Numbers
  1. Private Sub cbxControlName_Click()
  2.     cbxControlName.RowSource = "SELECT DISTINCT Table.Column FROM Table ORDER BY Table.Column"
  3. End Sub
As for requerying a subform, try:
Expand|Select|Wrap|Line Numbers
  1. Me.SubFormName.Requery
Depending on which point you wish to requery, you will have to place your code in the control's Sub that you're changing to force the requery. If it's upon navigating records, you will have to put it in your Form_Current Subroutine.

As for the other part, I'm afraid I will not be able to assist...
1) For the combo box I believe you wanted me to put the code in the OnClick property. I replaced all the instances where you had "Table" with the name of my table:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Combo20_Click()
  2.     Combo20.RowSource = "SELECT DISTINCT table1.Column FROM table1 ORDER BY table1.Column"
  3. End Sub
  4.  
I'm afraid it didn't change the results.
How should I modify the Control Source and Raw Source properties? Or should I touch em at all?

2)
For the subform issue.
I want the data to go in the subform when I press the search button so I put the
Me.QBF_Query_Subform.Requery
in the OnClick event of the button. I also tried to put it in the BeforeUpdate Sub. Now I keep getting the following:
"You didn't specify search criteria with a FindRecornd action."

I'm clearly doing something wrong.
Thanks!
Apr 20 '07 #3
Corster
36
1) ...I replaced all the instances where you had "Table" with the name of my table:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Combo20_Click()
  2.     Combo20.RowSource = "SELECT DISTINCT table1.Column FROM table1 ORDER BY table1.Column"
  3. End Sub
  4.  
I'm afraid it didn't change the results.
How should I modify the Control Source and Raw Source properties? Or should I touch em at all?
It is always best practise to name your controls accordingly; something relating to what type it is and what it does - like cbx for ComboBoX and SrchList for Search List. You will need to change the column name aswell - the things you should be changing have been placed within parentheses: (These things.()()())
Expand|Select|Wrap|Line Numbers
  1. Private Sub (ControlName)_(EventProcedure)
  2.     (ControlName).RowSource = "SELECT DISTINCT (TableName).(ColumnName) FROM (TableName) ORDER BY (TableName).(ColumnName)"
  3.  
2)
For the subform issue.
I want the data to go in the subform when I press the search button so I put the
Me.QBF_Query_Subform.Requery
in the OnClick event of the button. I also tried to put it in the BeforeUpdate Sub. Now I keep getting the following:
"You didn't specify search criteria with a FindRecornd action."

I'm clearly doing something wrong.
Thanks!
Yeah, I've tried making a search tool and I didn't get anywhere, I was trying to use FindFirst after setting focus on my txtSearch control. There may be another post here somewhere that might help with that.
Apr 24 '07 #4

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

Similar topics

1
by: El_Embozador | last post by:
Hi , please can you tell how i can print an MS ACCESS Report form visual basic, i ned a sample code .. Thanks
14
by: deko | last post by:
For some reason this does not seem to be working... Am I missing something basic? Dim rst As DAO.Recordset Dim db As DAO.Database Set db = CurrentDb Set rst = db.OpenRecordset("qryEmailS") '...
7
by: jim Bob | last post by:
Hi, This is probably very simple to do so if anyone can point me to the right place for reading, it would be much appreciated. I just want to build a very basic search form where i can enter a...
3
by: MarkusJNZ | last post by:
Hi, does anyone know of a good (Preferably free but don't mind paying some $$ for source code) basic document sharing application? Basically, a single admin should be able to upload files to a...
1
by: CodeGunnerLev1 | last post by:
Hey Guys How r ya? hey I am new in this thing and I think this is awesome place to be in.... Say I want to ask you guys a question. I need to know how can I produce a search button (search...
1
by: ApexData | last post by:
I am in the process of eliminating too many ComboBoxes used for searching. My MainForm will have a Button that will launch a PopUp Search Form. This SearchForm is a continuous form that has...
28
by: Randy Reimers | last post by:
(Hope I'm posting this correctly, otherwise - sorry!, don't know what else to do) I wrote a set of programs "many" years ago, running in a type of basic, called "Thoroughbred Basic", a type of...
43
by: Bill H | last post by:
25 years ago every computer came with some form of Basic interpreter so you could use yoru computer without having to buy more software. Is Javascript (teamed with HTML) set to become the new...
4
by: onyris | last post by:
-------------------------------------------------------------------------------- Hi guys , have 2 questions if anyone can help me . first - have a form which displays all the records i have in...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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:
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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.