473,396 Members | 1,707 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,396 software developers and data experts.

Legacy data in combo boxes

I know that this is an age old question and it has been approached a
few times, but I've hit a wall and require some help.

I have various combo boxes that contain values that are both "current"
and "not current". The problem is if you try to limit the drop down to
only the "current" values then your old records show a blank if the
field contains a "not current" value.

One of the solutions I have found is this:
SELECT DISTINCTROW tblListBusArea.BusAreaID, tblListBusArea.BusAreaName, tblListBusArea.Active
FROM tblListBusArea
WHERE (((tblListBusArea.Active)=True))
OR (((tblListBusArea.BusAreaID)=[Forms]![frmSubmissions]![cboBusArea]))
ORDER BY tblListBusArea.BusAreaName;
.... in the Row Source and a requery in AfterUpdate event.

This solution works nicely on the main form, but doesn't work on a
subform.

The reason (I believe) I found for this is that Access will set the
combo boxes of the subforms when opening up the main form. If the
subform combo box contains "not current" value, then the combo box
remains blank, because the data had not been loaded when the rowsource
was created. Correct me if I'm wrong.

The code I'm using on the subform is:
SELECT tblListTeams.TeamID, tblListTeams.TeamName, tblListTeams.Active
FROM tblListTeams
WHERE (((tblListTeams.Active)=True))
OR (((tblListTeams.TeamID)=[Forms]![frmSubmissions]![chlSubResponses]![cboTeam]))
ORDER BY tblListTeams.TeamName;
I envisioned leaving the rowsource for the subform combo boxes blank
and only setting the rowsource in the OnCurrent event of the main form:
Me!chlSubResponses!sfrmResponsesEntry.Form!cboTeam s.RowSource =
"SELECT tblListTeams.TeamID, tblListTeams.TeamName, tblListTeams.Active
FROM tblListTeams WHERE (((tblListTeams.Active)=True))
OR (((tblListTeams.TeamID)=[Forms]![frmSubmissions]![chlSubResponses]![cboTeam]))
ORDER BY tblListTeams.TeamName;"
but that gives me the error:
You entered an expression that has an invalid reference to the property Form/Report.

The property may not exist or may not apply to the object you specified.
I'm lost... Please help.

Jul 6 '06 #1
7 1810
Let the query for the combobox select all records.

But in the before update event for the box, where it is used, test to
see if it is active and cancel the event if the selection is NOT active
and give an error msgbox to that effect.

Ron

Jul 6 '06 #2
If you have this code in a Form, and that Form works as a main Form, but
does not work when embedded in a Subform, it is quite likely that your
reference to the Form is the problem. Only _open_ Forms are in the Forms
collection; a Form displayed in a SubformControl is not "open" -- the
instance you are viewing exists as the Form property of the Subform Control.

In a query, to reference a Control named "Joe" on the Form displayed in a
Subform Control named "Subf" which is on main Form named "Mai"

Forms!Mai!Subf.Form!Joe

If I have misunderstood, please clarify.

Larry Linson
Microsoft Access MVP


Jul 6 '06 #3

Something I did not make clear before is that the subform is in
Continous view. I will probably use Ron's suggestion as the List is
not very long and add a second Column to the drop-down to give a visual
clue to the status of a selection. Or I'll stop being nit-picky and
just live with it.

Larry, thanks. The info on _open_ forms does make things clearer. I
have tried referring to the subform in different ways.

Form= sfrmResponsesEntry
SubformControl = chlSubResponses
ComboBox = cboTeams
Me!chlSubResponses!sfrmResponsesEntry.Form!cboTeam s.RowSource = ""
and
Me!chlSubResponses.Form!cboTeams.RowSource = ""
both give me the same error.

Is putting the code in the main forms OnCurrent event the correct place?

Jul 10 '06 #4
Have a look at my post:
http://groups.google.com/group/comp....74232ef371f8ec
(http://tinyurl.com/o4ybh)

Since that writing I have figured out that it can actually be a bit
simpler than this, though II'm really crushed with work right now and
I'm not sure I'll be able to update this anytime in the next week or
so.

Still, it does work as described in that posting.

Jeremy

badboybrown wrote:
Something I did not make clear before is that the subform is in
Continous view. I will probably use Ron's suggestion as the List is
not very long and add a second Column to the drop-down to give a visual
clue to the status of a selection. Or I'll stop being nit-picky and
just live with it.

Larry, thanks. The info on _open_ forms does make things clearer. I
have tried referring to the subform in different ways.

Form= sfrmResponsesEntry
SubformControl = chlSubResponses
ComboBox = cboTeams
Me!chlSubResponses!sfrmResponsesEntry.Form!cboTeam s.RowSource = ""
and
Me!chlSubResponses.Form!cboTeams.RowSource = ""

both give me the same error.

Is putting the code in the main forms OnCurrent event the correct place?
Jul 10 '06 #5
Jeremy,

Thanks, your idea works great and loads the rowsource as required.

My only issue now, is that the combo box is the first field in the
subform and it doesn't fire the dropdown automatically and doesn't load
the rowsource until I tab past and then return. Also, if I mouseclick
directly onto the dropdown, the rowsource is blank until I click away
and then try again.

The combo box is the first field in the TabOrder and additionally I've
tried setting the focus to the combobox in the OnEnter event of the
SubFormControl.

Jul 18 '06 #6
Further to this:

Putting a date field first, and having the combo second solves
everything.

I can live with it.

Thanks for all your help.
badboybrown wrote:
Jeremy,

Thanks, your idea works great and loads the rowsource as required.

My only issue now, is that the combo box is the first field in the
subform and it doesn't fire the dropdown automatically and doesn't load
the rowsource until I tab past and then return. Also, if I mouseclick
directly onto the dropdown, the rowsource is blank until I click away
and then try again.

The combo box is the first field in the TabOrder and additionally I've
tried setting the focus to the combobox in the OnEnter event of the
SubFormControl.
Jul 18 '06 #7
Yeah, unfortunately, I had to do the same in one of my forms. I'll let
you know if I come up with a way around that.

Jeremy Wallace
Fund for the City of New York
metrix daht fcny daht org

badboybrown wrote:
Further to this:

Putting a date field first, and having the combo second solves
everything.

I can live with it.

Thanks for all your help.
badboybrown wrote:
Jeremy,

Thanks, your idea works great and loads the rowsource as required.

My only issue now, is that the combo box is the first field in the
subform and it doesn't fire the dropdown automatically and doesn't load
the rowsource until I tab past and then return. Also, if I mouseclick
directly onto the dropdown, the rowsource is blank until I click away
and then try again.

The combo box is the first field in the TabOrder and additionally I've
tried setting the focus to the combobox in the OnEnter event of the
SubFormControl.
Jul 20 '06 #8

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

Similar topics

0
by: Paul Edwards | last post by:
I am writing in c# with Visual Studio 2003. I am creating a form that shows one record from a Dataset that is populated with only one record from SQL Server 2000. I am using bound controls, both...
1
by: edworboys | last post by:
I have a form (Prospect) with a subform (Document). The result I am looking for is this: The user selects a prospect which is made up of Prospect Name, Country, Company and Prospect Type. They...
0
by: Tom | last post by:
I have some very strange issues with combo boxes on a tab control. Here's the scenario: I have a Windows Forms form that has a tab control on it, with two (2) tabs. Tab 2 happens to have a number...
4
by: Miguel | last post by:
I have an order entry database with two forms. One is for new orders the other is to update orders. The forms are identical except that one is strictly order entry. On both forms are three sets of...
7
by: Darhl Thomason | last post by:
Does VB2005 have a wizard for creating a form based on an Access db? I know that VB6 had this, but I can't seem to find anything similar in VB2005. Thanks! Darhl
8
by: AA Arens | last post by:
Hi I do have a products table and products-parts table in my Access 2003 database and log all services into a form. I do have at least the following two combo boxes on my form: - Choose...
3
by: Max | last post by:
Hello, I made a windows form with a combo box and 4 text boxes. All 5 objects should get their data from a data set which is populated in the form load method. The combo box has item ids. When...
2
by: Dave | last post by:
I have 3 tables of information feeding into 4 combo boxes on my main form (DR Form). I have as many list boxes (acting as text boxes) as there are fields in each one of the 3 tables. Once...
11
by: jgoodnight | last post by:
Hi, I have a form with three combo boxes: Area, Sub-Area, and Factor. I've set up the Sub-Area combo box to list only those areas that are part of the selected area. I've set up the Factor combo...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
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,...
0
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...
0
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.