473,626 Members | 3,369 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 (((tblListBusAr ea.Active)=True ))
OR (((tblListBusAr ea.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.Te amID, tblListTeams.Te amName, tblListTeams.Ac tive
FROM tblListTeams
WHERE (((tblListTeams .Active)=True))
OR (((tblListTeams .TeamID)=[Forms]![frmSubmissions]![chlSubResponses]![cboTeam]))
ORDER BY tblListTeams.Te amName;
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!chlSubRespon ses!sfrmRespons esEntry.Form!cb oTeams.RowSourc e =
"SELECT tblListTeams.Te amID, tblListTeams.Te amName, tblListTeams.Ac tive
FROM tblListTeams WHERE (((tblListTeams .Active)=True))
OR (((tblListTeams .TeamID)=[Forms]![frmSubmissions]![chlSubResponses]![cboTeam]))
ORDER BY tblListTeams.Te amName;"
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 1845
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= sfrmResponsesEn try
SubformControl = chlSubResponses
ComboBox = cboTeams
Me!chlSubRespon ses!sfrmRespons esEntry.Form!cb oTeams.RowSourc e = ""
and
Me!chlSubRespon ses.Form!cboTea ms.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= sfrmResponsesEn try
SubformControl = chlSubResponses
ComboBox = cboTeams
Me!chlSubRespon ses!sfrmRespons esEntry.Form!cb oTeams.RowSourc e = ""
and
Me!chlSubRespon ses.Form!cboTea ms.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
1821
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 text boxes and Combo Boxes (populated successfuly from same data source). When I use the fill command for the SQLDataAdaptor I can get the data by querying the dataset but the controls on the form do not show the data. If I set a combo box to...
1
2322
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 can then use the subform to add records into the database with the above information already there. At the moment I have four combo boxes in the Prospect part of the form.
0
1592
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 of text and combo boxes on it (in panels on the tab). These combos were originally simple drop down lists - i.e. you had to select from the list and couldn't enter anything of your own. At that time everything worked fine. Now, the users...
4
2495
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 sychronized combo boxes. When entering test data everything worked perfectly. I recently migrated 5,000+ records from an Excel file to the database. The migration was successful and all records were copied over. When I checked the underlying...
7
1337
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
2196
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 Product where as the Row Source (See properties): SELECT tblProducts.ProductName, tblProducts.ProductName FROM tblProducts ORDER BY ProductName;
3
2437
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 the users selects an item from the combo box I'd like the 4 text boxes to get populated with the corresponding item information from the same dataset table row that the combo box is pulling it's info from. Is there an easy way of doing this besides...
2
3265
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 selecting from the combo box, I have all the combo boxes, using afterupdate, populating their respective list boxes. These text boxes are directly correlated to the combo box selection using SQL. Here is an example from the afterupdate event in the...
11
3045
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 box to list only those factors that are part of the selected sub-area. For example, if I select area 1.0, the Sub-Area combo box displays 1.1, 1.2, and 1.3 as options. It does not show 2.1, 3.1, etc. If I select area 2.0, the Sub-Area combo box...
0
8705
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...
1
8364
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
8504
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
7193
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6125
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
5574
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();...
1
2625
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
1
1808
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1511
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.