473,666 Members | 2,278 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Lost - Please help with a query

Hi,

I have nearly finished my database and I would like to add a query
that uses a combo box to get the results, not the usual paramater
style input. I suppose it would need a form and a query and a combo
box, but where to start !!!!!!!!

Any kind soul out there that can give me an example of where to
start.......... ?

Many Thanks

Joe

Apr 6 '07 #1
5 2018
On 6 Apr 2007 14:47:34 -0700, deaconj999 wrote:
Hi,

I have nearly finished my database and I would like to add a query
that uses a combo box to get the results, not the usual paramater
style input. I suppose it would need a form and a query and a combo
box, but where to start !!!!!!!!

Any kind soul out there that can give me an example of where to
start.......... ?

Many Thanks

Joe
Is the query to be viewed by itself, or is it used as the recordsource
for a report.
Different methods.
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
Apr 6 '07 #2
Hi,

What you really meant to say was "use a combo-box to specify criteria"
instead of being prompted for it as per the usual (eg [Enter a nuber between
1 and 6] )parameter query, right?

My suggestion,( if this is what you want) is to design an unbound main form
to put your combo-box on, and a datasheet style subform that will be used to
display the results.

Use the combo-boxes AfterUpdate to build your SQL statement (query) in code,
and then use the resulting SQL as the RecordSource for the subform.
Here is a code sample:
=============== ========

Public Sub sRequerySubform ()
'What I want to do here is build the RecordSource for the subform
'ON-THE-FLY...to allow for a variable WHERE statement.
'IF the user wants to view:
' 1.) ALL records
' The combo-box also has an "All" option. Instructions at
http://www.mvps.org/access/forms/frm0043.htm

' 2.) filtered by Line code (a 3-character brand abbreviation)

Dim MySQL As String
Dim RptSQL As String
Dim whr As String

Dim MyLine
MyLine = Me![cboLine]

'Build the SELECT portion of the SQL statement
MySQL = ""
MySQL = MySQL & "SELECT tblPartsInvento ry.* FROM tblPartsInvento ry "

'Build the WHERE portion
whr = "" 'initialize variable

If Not IsNull(MyLine) And MyLine <"(All)" Then
whr = whr & "(tblPartsInven tory.Line = '"
whr = whr & MyLine
whr = whr & "' )"
MySQL = MySQL & "WHERE ("
MySQL = MySQL & whr
MySQL = MySQL & ") "
End If

'The report will use the same SQL except it needs this line added.
RptSQL = MySQL & "And (tblPartsInvent ory.Selected = True)" & ";"

MySQL = MySQL & "ORDER BY tblPartsInvento ry.Line,
tblPartsInvento ry.PartNumber "
MySQL = MySQL & ";"

'Debug.Print "MySQL: " & MySQL
'Debug.Print "-------------------------" & CR
'Debug.Print "RptSQL: " & RptSQL
Me![sbfBinLabelSele ction].Form.RecordSou rce = MySQL

End Sub

=============== ===

--
--
HTH,
Don
=============== ==============
E-Mail (if you must) My*****@Telus.n et

Disclaimer:
Professional PartsPerson
Amateur Database Programmer {:o)

I'm an Access97 user, so all posted code samples are also Access97- based
unless otherwise noted.

=============== =============== =============== =============== ==============
"deaconj999 " <de********@bti nternet.comwrot e in message
news:11******** **************@ y66g2000hsf.goo glegroups.com.. .
Hi,

I have nearly finished my database and I would like to add a query
that uses a combo box to get the results, not the usual paramater
style input. I suppose it would need a form and a query and a combo
box, but where to start !!!!!!!!

Any kind soul out there that can give me an example of where to
start.......... ?

Many Thanks

Joe

Apr 7 '07 #3
On Apr 6, 5:47 pm, "deaconj999 " <deaconj...@bti nternet.comwrot e:
Hi,

I have nearly finished my database and I would like to add a query
that uses a combo box to get the results, not the usual paramater
style input. I suppose it would need a form and a query and a combo
box, but where to start !!!!!!!!

Any kind soul out there that can give me an example of where to
start.......... ?

Many Thanks

Joe
Joe,

1. Create a query to "feed" the combo box, including only the fields
you want to appear in the combo box.

2. Create an unbound form or use an existing form, depending on from
where you want the user to conduct the search.

3. Put a combo box on your form, using your query from step 1 as the
row source. (I like to use the wizard for combo boxes. Click the
wizard button on the tool bar before you place the combo box on your
form, and then just answer the questions to set up the combo box.)
Give the combo box a name or remember the one Access gave it.

4. Decide how you want the user to initiate the search. I would
suggest a couple of buttons on the form; one thats says "Search" and
one that says "Cancel".

5. Create another query for your search results. In the criteria blank
for the field in this query that matches the combo box type: Like
"[Forms]![Name of Your Form]![Name of your combo box]". (If the field
is numeric or date/time, as opposed to text, use = instead of Like.)

6. Create macrosnfor the buttons. If you choose "Macro Names" from the
View menu, you can place both of the macros is the same macro group.
For the "Search" macro, merely use an OpenQuery command to open the
search result query. For the "Cancel" macro, use a Close command on
the search form.

7. If you would rather the user view the search results in a form or
report instead of a query, create one, using the query as the control
source.

That's the simplest way I know of to do it and it doesn't involve any
knowledge of VBA.

Good luck.

Steve

Apr 7 '07 #4
On Apr 7, 4:53 am, scart...@alltel .net wrote:
On Apr 6, 5:47 pm, "deaconj999 " <deaconj...@bti nternet.comwrot e:
Hi,
I have nearly finished my database and I would like to add a query
that uses a combo box to get the results, not the usual paramater
style input. I suppose it would need a form and a query and a combo
box, but where to start !!!!!!!!
Any kind soul out there that can give me an example of where to
start.......... ?
Many Thanks
Joe

Joe,

1. Create a query to "feed" the combo box, including only the fields
you want to appear in the combo box.

2. Create an unbound form or use an existing form, depending on from
where you want the user to conduct the search.

3. Put a combo box on your form, using your query from step 1 as the
row source. (I like to use the wizard for combo boxes. Click the
wizard button on the tool bar before you place the combo box on your
form, and then just answer the questions to set up the combo box.)
Give the combo box a name or remember the one Access gave it.

4. Decide how you want the user to initiate the search. I would
suggest a couple of buttons on the form; one thats says "Search" and
one that says "Cancel".

5. Create another query for your search results. In the criteria blank
for the field in this query that matches the combo box type: Like
"[Forms]![Name of Your Form]![Name of your combo box]". (If the field
is numeric or date/time, as opposed to text, use = instead of Like.)

6. Create macrosnfor the buttons. If you choose "Macro Names" from the
View menu, you can place both of the macros is the same macro group.
For the "Search" macro, merely use an OpenQuery command to open the
search result query. For the "Cancel" macro, use a Close command on
the search form.

7. If you would rather the user view the search results in a form or
report instead of a query, create one, using the query as the control
source.

That's the simplest way I know of to do it and it doesn't involve any
knowledge of VBA.

Good luck.

Steve
Many thanks

Apr 7 '07 #5
On Apr 7, 1:47 am, "deaconj999 " <deaconj...@bti nternet.comwrot e:
On Apr 7, 4:53 am, scart...@alltel .net wrote:


On Apr 6, 5:47 pm, "deaconj999 " <deaconj...@bti nternet.comwrot e:
Hi,
I have nearly finished my database and I would like to add a query
that uses a combo box to get the results, not the usual paramater
style input. I suppose it would need a form and a query and a combo
box, but where to start !!!!!!!!
Any kind soul out there that can give me an example of where to
start.......... ?
Many Thanks
Joe
Joe,
1. Create a query to "feed" the combo box, including only the fields
you want to appear in the combo box.
2. Create an unbound form or use an existing form, depending on from
where you want the user to conduct the search.
3. Put a combo box on your form, using your query from step 1 as the
row source. (I like to use the wizard for combo boxes. Click the
wizard button on the tool bar before you place the combo box on your
form, and then just answer the questions to set up the combo box.)
Give the combo box a name or remember the one Access gave it.
4. Decide how you want the user to initiate the search. I would
suggest a couple of buttons on the form; one thats says "Search" and
one that says "Cancel".
5. Create another query for your search results. In the criteria blank
for the field in this query that matches the combo box type: Like
"[Forms]![Name of Your Form]![Name of your combo box]". (If the field
is numeric or date/time, as opposed to text, use = instead of Like.)
6. Create macrosnfor the buttons. If you choose "Macro Names" from the
View menu, you can place both of the macros is the same macro group.
For the "Search" macro, merely use an OpenQuery command to open the
search result query. For the "Cancel" macro, use a Close command on
the search form.
7. If you would rather the user view the search results in a form or
report instead of a query, create one, using the query as the control
source.
That's the simplest way I know of to do it and it doesn't involve any
knowledge of VBA.
Good luck.
Steve

Many thanks- Hide quoted text -

- Show quoted text -
I'll toss in one more approach. I'm assuming that all you need is a
different filter on the report (the usual). If so, then use the combo
box to get what it is to be reported on. You can then use the filter
on the report open code to have the report show what is desired. For
example

docmd.openrepor t "MyReport", ,,, "Key = " & me.comboBox

I don't remember off-hand how many commas are needed here, but VBA
will show you the arguments once you start typing.

-- Larry Engles

Apr 8 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3483
by: Bartosz Wegrzyn | last post by:
Hi, I have simple web with authentication. My main page looks like this: <?php include ("nav.htm"); include ("auth.php"); $menu = $_GET;
0
1568
by: jackson marshmallow | last post by:
I have just recreated several (large) tables in the database as InnoDB and reloaded them using my client application... These tables used to be MyISAM. I haven't tried playing with any InnoDB parameters, right now everything is default. Some operations a noticeably slower, which can probably be fixed. Speed is not essential right now. But I did run into one strange problem with a batch INSERT SELECT that would take about an hour with...
3
5443
by: Matias Silva | last post by:
Hi Everyone, I wrote a for loop to build several select statements that are combined with a UNION. When I execute one of the queries separately, it works, but when I execute the query with a UNION it returns: ERROR 2013 (HY000): Lost connection to MySQL server during query I am able to run additional queries after I get the error, so the connection is not lost. I have tried running the query with the union on MySQL Query Browser and...
6
1444
by: garyusenet | last post by:
I have created a new project. and within this project as per the tutorial created an sql database. i have made a query which returns the result i need. 1. I cant SAVE THE QUERY? where on earth is the option to save a query? 2. How do i run an sql query from within c# ? i have a command button i want to enter code for the command button that will run an sql query... how do i do it?
7
1560
by: VB Programmer | last post by:
I've lost the Data Sources tab (in Whidbey). How can I make it reappear? I need to "Add New Data Source..." Thanks!
6
8352
by: Vyoma | last post by:
This is quite a bit of problem I am facing, and I cannot point exactly where I am going wrong. I have been lurking around at several forums with regard to login and user authentication scripts and I have got as far as this: - Starting a session - Registering a session variable - Using the variable to check if the user is authenticated or not. - Authenticating the user through MySQL database - Logging of the user, by setting the...
0
1726
by: Bruno Barberi Gnecco | last post by:
I'm using stored procedures in a PHP site, with mysql. I'm having problems with stored procedures. Of the two I'm using, one works all the time, consistently. The other works correctly, but the next query returns "Lost connection to MySQL server during query" and subsequently: "MySQL server has gone away". I'm using MDB2 to access the database. I tried changing the driver from 'mysql' to 'mysqli', with little success. Currently, about...
13
3053
by: SAL | last post by:
Okay, don't bash me to hard for my design on this app, it's my first web app and it's in production. My basic design is using Datatables created via the designer with a business logic class in between the datatable and ObjectDataSources. In one page I had a Gridview with select enabled. When an row in the grid is selected, I retrieve the SelectedValue, store the value in a Session variable and redirect the response to another web page,...
2
1738
by: Nightcrawler | last post by:
I have the following tables that I have dragged into a .dbml file ( have only included the keys for simplicity). Users have a one to many relationship on Items keyed on UserId = UserId. Users have a one to many relationship on UserFriend keyed on UserId = UserId and UserId = FriendId CREATE TABLE .( NOT NULL,
0
8355
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8866
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8781
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
6191
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5662
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4365
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2769
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2006
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1769
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.