473,734 Members | 2,789 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Unbound Combo Box Record Selector Question

I'm using an unbound combo box on a form as a record selector. I'm
using the combo box to choose certain types of music, i.e.
Alternative, Pop, Rock, etc…and then run a report based on the
selection.

My combo box, cboMuisicType, has a simple query, qryGetType, as a row
source. This query retrieves data from my table, tblMusicTypes. This
table has 2 fields: MusicID and MusicDesc. MusicID is the primary key
and an autonumber. MusicDesc is a description of the music, i.e.
Alternative, Pop, Rock, etc…

tblMusicTypes:

MusicID | MusicDesc
1 Alternative
2 Pop
3 Rock
The combo box is also the criteria of my query, qryGetType:
[MusicForm][cboMusicType]
Right now, I have no problem choosing one of the types of music in my
combo box and generating a report based on that selection. However,
I'd like to add a choice to my combo box that would allow me to choose
all of the types of music and then generate a report. For example,
selecting the word, "All," from my combo box, cboMusicType, would
generate a report based on all of the types of music in my table,
tblMusicTypes.

So I'm wondering what the best/ simplest way to do this is.

Should I add "All" to my table, tblMusicTypes?

Thanks!

Megan
Nov 13 '05 #1
6 2772
yes or you can make a union query (do you know how to do this???), with
additional options.

Otherwise you can also change the combobox into a listbox with the
multiselection option set to true.

Let me know what would suit best.

- Nicolaas
Nov 13 '05 #2
"WindAndWav es" <ac****@ngaru.c om> wrote in message news:<0A******* ***********@new s.xtra.co.nz>.. .
yes or you can make a union query (do you know how to do this???), with
additional options.

Otherwise you can also change the combobox into a listbox with the
multiselection option set to true.

Let me know what would suit best.

- Nicolaas


I think I know how to do a union query. It's like query1 union query2
union query3, etc... right? But I'm unsure how to use it with a combo
box.

I've never used a listbox before. So, I'll look at some posts here to
see if I can figure it out.

Thanks for the suggestions!!!

Megan
Nov 13 '05 #3
If your form has space for a list box then it would definitely be better. In
that case your user can make any selection.

Another way to do this is to add an extra field to your table that you call
something like Sel (for select) of the boolean type.

the nice thing about using a tickbox is that it will retain its value, so if
the user wants to (most of the time) print a report for Britney Spears and
Madonna, then it will retain this selection.

Here are some generic functions that I use for controlling listboxes. Note
that you need to set them to multiselect (on the Other Tab) to use these
functions. Also note that they will need some reworking for your
application.

Option Compare Database
Option Explicit
Const ModEro = 9933
'other list operations

Public Function FuCIS(FrmN As String, CtlN As String) As String
'returns a string that tells you how many controls are selected
On Error GoTo ERR
'---
Dim FRM As Form
Dim Ctl As Control
Dim Itm As Variant
Dim X As Long
Dim Y As Long
'---
Set FRM = Forms(FrmN)
Set Ctl = FRM.Controls(Ct lN)
'---
For Each Itm In Ctl.ItemsSelect ed
X = X + 1
Next Itm
If X = 0 Then
FuCIS = "none"
Else
Y = Ctl.Recordset.R ecordCount
If X = Y Then
FuCIS = "all"
Else
FuCIS = X & "/" & Y
End If
End If
xit:
Exit Function
ERR:
FuCIS = "N/A"
Resume xit
End Function
Public Function FuSLI(FrmN As String, CtlN As String, REC As Long, bNew)
'selects a particular item on a multi-selection list
'REC = the ID of the item to selected
'bnew identifies whether it should be selected or unselected
Const ProEro = 3: 'On Error GoTo err
'---
Dim FRM As Form
Dim Ctl As Control
Dim Itm As Variant
Dim I As Long
'---
Set FRM = Forms(FrmN)
Set Ctl = FRM.Controls(Ct lN)
'---
For I = 0 To Ctl.ListCount - 1
If Ctl.ItemData(I) = REC Then
Ctl.Selected(I) = bNew
End If
Next I
xit:
Exit Function
ERR:
Resume xit
End Function
Public Function MultiSelectW(FR M As Form, Ctl As Control, TBL As String) As
String
'creates a WHERE statement for a multi select listbox
'the WHERE statement can filter for for IDs of the items selected
Const ProEro = 1: 'on error GoTo err
'---
Dim Row As Variant
Dim ID As Long
'---
If Ctl.ItemsSelect ed.COUNT < 1 Or Ctl.ListCount < 1 Then
MultiSelectW = "Where [" & TBL & "-ID]>=0"
GoTo xit
Else
For Each Row In Ctl.ItemsSelect ed
ID = Ctl.Column(0, Row)
MultiSelectW = MultiSelectW & "[" & TBL & "-ID]=" & ID & "
OR "
Next Row
MultiSelectW = Left(MultiSelec tW, Len(MultiSelect W) - 4)
End If
xit:
Exit Function
ERR:
Call FerrorLog(ERR.N umber, 0, ProEro + ModEro): Resume xit
end function
End Function



Nov 13 '05 #4
me************* *@hotmail.com (Megan) wrote in message news:<5c******* *************** ****@posting.go ogle.com>...
So I'm wondering what the best/ simplest way to do this is.

Should I add "All" to my table, tblMusicTypes?

Thanks!

Megan


Although it's not difficult to put the word "all" in your combobox,
consider letting a blank value in the combobox mean "all." For search
forms with lots of search fields it would complicate things
unnecessarily to put "all" in for each search field. It's just as
easy to check for a Null value as an "all" value. It also makes sense
when you think of filtering records based on a value. No value means
no filtering. Here "no filtering" means having no WHERE clause.
Note: some people like to use the Report's Filter property to specify
criteria. The reason using blank values for "all" works reasonably
well is that people seldom search for values that are Null.

James A. Fortune
Nov 13 '05 #5
Hey-

Thanks for your suggestions and time! I truly appreciate it!

If you don't mind, I'd like to pose this follow-up hypothetical
situation...

1.) What if I add "All" to my table, tblMusicTypes,
tblMusicTypes:

MusicID | MusicDesc
1 Alternative
2 Pop
3 Rock
4 All

2.) Use this SQL statement:

SELECTMusicID, MusicDesc FROM tblMusicTypes UNION SELECT NULL AS
AllChoice, "(All)" AS cboAll FROM tblMusicTypes;

I was reading through the newsgroup and saw a link to the web site,
The Access Web (http://www.mvps.org/access/). On their Form's page,
they had this situation and a possible solution-- a union query as
"WindAndWav es" suggested.

But...I'm unsure of the code, such as the word "AllChoice. " Is this an
Access keyword?

Plus, are the "()" needed around the word, All, in the part: "(All)"
AS cboAll FROM tblMusicTypes;

I'm going to try this, and I'll let you know how it goes so that if
anybody else has this situation, they can read this post and find a
solution!
"I'll be Baaack!" :-)

Thanks All!

Megan
Nov 13 '05 #6
me************* *@hotmail.com (Megan) wrote in message news:<5c******* *************** ****@posting.go ogle.com>...
Hey-

Thanks for your suggestions and time! I truly appreciate it!

If you don't mind, I'd like to pose this follow-up hypothetical
situation...

1.) What if I add "All" to my table, tblMusicTypes,
tblMusicTypes:

MusicID | MusicDesc
1 Alternative
2 Pop
3 Rock
4 All
Megan,

The idea behind using the Union Query was to make the word "All"
available without putting it in the table. Sometimes the criteria for
filling a combobox is more complicated than in your case and being
able to add "All" without putting it in a table is desirable. The
Union Query also allows you to put the word "All" at the beginning or
at the end of the combobox regardless of the alphabetic order that
would normally result. You could also get "All" from the table in the
spot you want by including an "ORDER BY MusicID" clause in the SQL
statement used as a RecordSource for the combobox and swapping
MusicDesc values to get the desired order.

2.) Use this SQL statement:

SELECTMusicID, MusicDesc FROM tblMusicTypes UNION SELECT NULL AS
AllChoice, "(All)" AS cboAll FROM tblMusicTypes;

If you don't put the word 'All' in tblMusicTypes then you can use
something like:

SELECT 'All' As MusicDesc, 0 As MusicID FROM tblMusicTypes UNION
SELECT MusicDesc, MusicID FROM tblMusicTypes ORDER BY MusicID;

to use the MusicID to get the desired list order or:

SELECT 'All' As MusicDesc FROM tblMusicTypes UNION SELECT MusicDesc
FROM tblMusicTypes ORDER BY MusicDesc;

to have 'All' as the first entry followed by the rest of the
selections alphabetized.

Hope this helps (hypothetically :-)),

James A. Fortune
"I'll be Baaack!" :-)

Thanks All!

Megan

Nov 13 '05 #7

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

Similar topics

7
2365
by: Aravind | last post by:
Hi folks. I have 2 forms, frmBorrow and frmHistory frmBorrow has an unbound multi-column combo box (cboMember) and 7 unbound text boxes (MemNo, MemName, MemIC, MemType, CourseFaculty, Borrow, Due) frmHistory has the following text boxes: MemName, Borrow, Due
7
2266
by: Megan | last post by:
Hi everybody- I inherited a database that somehow uses a bound combo box as a record selector. Let me give you some background. The form is based on data from 2 tables. The first table, Person, records info about a person. The second table, Case, records information about a person's case, almost like a human resources database. The primary key of the table, person, is his/ her social security number. The primary key of the other...
2
6159
by: Todd | last post by:
Hello, I'm curious if anyone knows of a way (if one exists) to tell a form (in Access 2002 VBA) to sort on an unbound column of a combo box on the form. Here's what I want to do: A combo box on my form contains a category ID (bound column, not visible, long integer) for the items listed on the form and a description (unbound column, visible, string.) I can "Sort Ascending" and "Sort Descending" on the visible description in the...
2
3086
by: Wolfgang Kreuzer | last post by:
Hello all, I am converting an Axs 2.0 application to a2k (I know A2K is not the most current version but Axs 2.0 support ended and A2K is supported in our company amd on every PC). The form is part of an access projcet (ADP) and runs against SQL Server 2000. I have an bound form in endless view which contains a header with a combobox. This combobox is bound to an access query and shall allow to
1
2967
by: BigJay | last post by:
I am 1. trying to have a combobox used as a selector to display records in a subform. and not sure on how to get selected info into subform.the combo is populated but can not get subform updated when selection is made..... 2. I also want to use one combo box to select a second set of criteria in a second combo box that is then used to refine displayrd records in a a subform.... am afraid im lost on this..??? I have a main table that...
20
10824
by: Robert | last post by:
Need some help to stop me going around in circles on this one.... Have a nested subform (subform2) which simulates a continuous form for the record on the parent subform. Subform2 has rows of either an option button plus two text fields or a checkbox plus two text fields Am wanting to save the user entries into an underlying table. Tag property for each option button, check box or text field has the value of the key
0
1444
by: annivanova | last post by:
Hi, I saw posts in Dependent listboxes on access forms, which problem is very similar to my. I’m working over to create an MS Access application. I used in my project given code : Code: Private Sub Country_AfterUpdate() With Me! If IsNull(Me!Country) Then ' if no country is selected .RowSource = "" ' leave row source of Region blank
6
13578
by: Rig20 | last post by:
Hello, I’m sure this is a relatively easy fix, but I have an unbound combo box on a form that runs numerous queries in the After Update section. Everything there works fine. All I need to do is have a command button on the form that advances the focus of the combo box to the next record in the query its row source is based on (plus I’m sure it will need an error catcher when it gets to the end of the list). I know how to advance the form’s...
7
12507
by: DeZZar | last post by:
Hi all, Unfortunately I am quite a novice with Access!! I've created a number of data bases for my work however becuase my skills are limited to really built in functionality and wizards my programs are not really user friendly. I have searched and searched and tried numerous times to get the following right to no avail - and I think its really becuase of my lack of understanding.
0
8946
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9310
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
9236
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9182
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6031
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
4550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4809
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2724
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2180
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.