combo box on unbound form with its rowsource property left blank

G

George

Hi to everybody,
I have been disappointed after having tried for so long to get an answer to
this question but I will give it a last try.

I am trying to learn object oriented programming and for this purpose I
decided to redesign an existing application using exclusively unbound forms.
(I stress this fact because in my previously posted questions, well-meaning
friends on this site have suggested easier ways to get my job done using
bound forms, but this is not what I want.)

I have an unbound form, frmClients, with text boxes, and combo boxes on it.
The form is based on table tblClients and class clsClient. At the bottom of
the form I have placed navigation, edit, add and delete buttons with code
behind them. So far I have managed to make everything work as expected except
one thing.

I don’t know how to deal with the combo boxes. For example, in my previous
corresponding bound form I had cboNationality which was using the look up
table tlkpNationalities [ NationalityID (long), Nationality (string) ] as its
row source to pick up its values. Now, through the code I have written I have
succeeded to pass the NationalityID field value from my table to the combo
box (I have checked on this) but nothing is displayed (naturally) as the
combo’s row source is left blank. I want the combo box to be completely
ignorant of the database’s tables and queries (as it should be in oop) and
that’s why I have left it blank.

How can I make cboNationality functional again on my currently unbound form,
provided that I leave its row source blank?
A. Do I have to create another class, clsNationality, and initialize it in
the initialize event of my clsClient and then proceed from there?
B. Do I need to add code that queries tlkpNationalities in my Let and Get
procedures of the private variable for the nationality or what?

I am totally in the dark and stuck for so long! I would appreciate any help
with practical advice. I have never used class modules before and the various
textbooks don’t cover this issue at all, they only deal with textboxes.

Thanks in advance, George
 
K

Klatuu

George,

I guess I don't fully understand your question. A combo box has to have a
row source or it will display nothing and there will be nothing to select.

Is it that you want to populate the row source from a class module?
As to the combo being indepentant from your database tables and queries,
other than a value list as the combo's row source, I don't know how you
indent to accomplish this. I guess you could have the Initialize event of
the class module populate the combo's row source with a value list.

To be honest, I think you have a misunderstanding of oop. I believe your
whole design concept is incorrect and you are abandoning the power of Access
in your approach. The very first Access application I ever worked on, guided
by another person did use all unbound forms, but after working on my own, I
found it much easier to use bound forms and the natural functionality built
into Access.

In case you are not aware, Access is not by the strictest definition an oop
development tool. It has many oop features, but does not support all oop
practices and principles.
--
Dave Hargis, Microsoft Access MVP


George said:
Hi to everybody,
I have been disappointed after having tried for so long to get an answer to
this question but I will give it a last try.

I am trying to learn object oriented programming and for this purpose I
decided to redesign an existing application using exclusively unbound forms.
(I stress this fact because in my previously posted questions, well-meaning
friends on this site have suggested easier ways to get my job done using
bound forms, but this is not what I want.)

I have an unbound form, frmClients, with text boxes, and combo boxes on it.
The form is based on table tblClients and class clsClient. At the bottom of
the form I have placed navigation, edit, add and delete buttons with code
behind them. So far I have managed to make everything work as expected except
one thing.

I don’t know how to deal with the combo boxes. For example, in my previous
corresponding bound form I had cboNationality which was using the look up
table tlkpNationalities [ NationalityID (long), Nationality (string) ] as its
row source to pick up its values. Now, through the code I have written I have
succeeded to pass the NationalityID field value from my table to the combo
box (I have checked on this) but nothing is displayed (naturally) as the
combo’s row source is left blank. I want the combo box to be completely
ignorant of the database’s tables and queries (as it should be in oop) and
that’s why I have left it blank.

How can I make cboNationality functional again on my currently unbound form,
provided that I leave its row source blank?
A. Do I have to create another class, clsNationality, and initialize it in
the initialize event of my clsClient and then proceed from there?
B. Do I need to add code that queries tlkpNationalities in my Let and Get
procedures of the private variable for the nationality or what?

I am totally in the dark and stuck for so long! I would appreciate any help
with practical advice. I have never used class modules before and the various
textbooks don’t cover this issue at all, they only deal with textboxes.

Thanks in advance, George
 
R

Rick Brandt

George wrote:
[snip]
I want the combo box to be completely
ignorant of the database's tables and queries (as it should be in
oop) and that's why I have left it blank. [snip]

Where on earth did you get this notion? OOP and "ignorant of your
database's tables and queries" have absolutely nothing to do with each
other. There is nothing about using classes and/or unbound forms that
dictates using ComboBoxes without RowSources.

Since Access/VBA isn't capable of real OOP (no inheritance, no polymorphism,
etc.), I suggest you obtain a tool that is for this excercise. As it is
you're trying to build a brick house out of wooden timbers.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top