Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Creating Specialized Objects with predetermined behaviours

0 views
Skip to first unread message

DawnTreader

unread,
Sep 1, 2010, 3:40:30 PM9/1/10
to
Hello All

i have a question that is more curiosity than immeadiate
implementation.

i have an app with a lot of places where i use combo boxes and list
boxes that hold a lot of the same type of thing over and over.

for instance i have a combo box for entering a city into a record in
no less that 4 places, maybe more. is it possible to build a bunch of
code that would then enable me to put a "City combo box" and it would
look up the information in a particular way, act according to a
predetermined set of rules and be placeable multiple times and have
them all do the same thing?

the idea is that each time i place a city combo box i have to set its
source and then code it to allow for not in list items and other
things. if i could code the behaviour once and then have the ability
to place that combo box where ever i wanted then it would simplify a
lot of work.

the same can be said of some list boxes i have, although these are a
little different. i have at least 5 that show different groupings of
information, orders, service reports, issues and such. could i create
a set of routines that would allow me to have one list box that would
be "swappable" with different data sets? can i set up parameters and
stuff and then apply those when the data source changes? things like
column widths and such as well as focus and double click behaviours?

thanks for any and all help.

Ken Snell

unread,
Sep 1, 2010, 7:30:20 PM9/1/10
to
Create a class module that will establish the rules for how the combo box is
to behave. Then, put a combo box on your form when you design the form; and
in the form's Load event, instantiate the class object and 'assign' it to
the class object.

I have a sample database that uses this concept for "combining a combo box
with a text box" in order to make a combo box that can be used when you hvae
more than 65000 items. Look at the class module code; look at how the class
is "assigned" to the combo box and text box that are on the form. This
should give you an idea for how to do what you want.

Text Box & Combo Box Combination
http://www.accessmvp.com/KDSnell/SampleDBs.htm#CombinedTextComboBoxes

--

Ken Snell
http://www.accessmvp.com/KDSnell/


"DawnTreader" <alan...@gmail.com> wrote in message
news:645d79ff-21e8-4d5f...@k1g2000prl.googlegroups.com...

DawnTreader

unread,
Sep 5, 2010, 2:28:47 PM9/5/10
to
On Sep 1, 4:30 pm, "Ken Snell" <kthsneisll...@ncoomcastt.renaetl>
wrote:

> Create a class module that will establish the rules for how the combo box is
> to behave. Then, put a combo box on your form when you design the form; and
> in the form's Load event, instantiate the class object and 'assign' it to
> the class object.
>
> I have a sample database that uses this concept for "combining a combo box
> with a text box" in order to make a combo box that can be used when you hvae
> more than 65000 items. Look at the class module code; look at how the class
> is "assigned" to the combo box and text box that are on the form. This
> should give you an idea for how to do what you want.
>
> Text Box & Combo Box Combination
>  http://www.accessmvp.com/KDSnell/SampleDBs.htm#CombinedTextComboBoxes
>
> --
>
>         Ken Snellhttp://www.accessmvp.com/KDSnell/
>
> "DawnTreader" <alanrt...@gmail.com> wrote in message

>
> news:645d79ff-21e8-4d5f...@k1g2000prl.googlegroups.com...
>
>
>
> > Hello All
>
> > i have a question that is more curiosity than immeadiate
> > implementation.
>
> > i have an app with a lot of places where i use combo boxes and list
> > boxes that hold a lot of the same type of thing over and over.
>
> > for instance i have a combo box for entering a city into a record in
> > no less that 4 places, maybe more. is it possible to build a bunch of
> > code that would then enable me to put a "City combo box" and it would
> > look up the information in a particular way, act according to a
> > predetermined set of rules and be placeable multiple times and have
> > them all do the same thing?
>
> > the idea is that each time i place a city combo box i have to set its
> > source and then code it to allow for not in list items and other
> > things. if i could code the behaviour once and then have the ability
> > to place that combo box where ever i wanted then it would simplify a
> > lot of work.
>
> > the same can be said of some list boxes i have, although these are a
> > little different. i have at least 5 that show different groupings of
> > information, orders, service reports, issues and such. could i create
> > a set of routines that would allow me to have one list box that would
> > be "swappable" with different data sets? can i set up parameters and
> > stuff and then apply those when the data source changes? things like
> > column widths and such as well as focus and double click behaviours?
>
> > thanks for any and all help.- Hide quoted text -
>
> - Show quoted text -

i have no idea what your sample is supposed to do. i suppose i should
ask is it compatible with 2010? if it is then it does nothing.

Ken Snell

unread,
Sep 5, 2010, 4:59:24 PM9/5/10
to
This sample database will not do what you're seeking to do; it's just an
example of how you can use a class module to "control" a control on a form
the way you want to do. It's written in ACCESS 2002/2003, so it should be
usable in 2010, but I haven't actually tried it in 2010 because I don't have
2010.

I have put a newer version of the database on the website; please download
it again. The zip file now also has a "READ ME" file that explains more
about this sample database.

In this sample database, you start to enter something in the textbox under
the heading "Enter a part number:". (Use the combobox next to "Full list of
part numbers" to see which part numbers are in the sample database.) As soon
as you've entered enough characters to let a combobox list to have fewer
than 26 rows

(in the form's module code, you'll see this code step:
'..tell module the maximum number of rows to be displayed in the
' combo box
cls_TextComboBoxes.ComboBoxMaxRows = 25
)

then the textbox "changes" to a combobox and lets you select a choice from
the dropdown list. Thus, the combobox allows the "creation" of a new type of
control for the form -- a "CombinationComboBoxTextBox" (for lack of a better
description!).

If you open the form's module's code, you'll see how the class module is
instantiated and then the textbox and combobox on the form are "assigned" to
the class module -- this allows the class module to control the two controls
on the form based on the "rules" in the class module. You'll note that the
code in the form allows you to set some parameters for the class module
(e.g., how many rows are the maximum to show in the combobox's dropdown
list, for example).

The class module's code shows you how the controls are controlled; events
are used from the form to trigger the class module's various event
procedures.

So, for your setup, you'd write a class module that would "do" what you want
for a "city combo box", and then you'd instantiate that class module in a
form's code, and assign a combobox to the class module's combobox object. At
that point, the combobox on your form would "behave" according to the logic
of a "city combo box".

I'm not trying to say this is an extremely simple thing to initially write,
but once you have it, it's really easy to use. And it's a way to do what you
seek for your "city combo box". You'd just create a form, put a combobox
control on the form, and add code to the form's module that attaches the
combobox to the class module.
--

Ken Snell
http://www.accessmvp.com/KDSnell/


"DawnTreader" <alan...@gmail.com> wrote in message

news:551db50f-5eb2-46d2...@g21g2000prn.googlegroups.com...

0 new messages