473,765 Members | 1,967 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Querying One Combo Box in Another

AllusiveKitten
43 New Member
Hi

I am hoping someone can help me, I have a form with two combo boxes in it.... The first combo box gets its values from a table via an SQL query in the combo box properties. The second combo box is supposed to get its values also via an SQL query in its properties but it is depending on the result of the first combo box...

ie. First combox has the names of all of the people who have received a document. (This combo box works perfectly well)

The second combo box is to show only the dates the person from the first combo box has received a document. These values come through correctly when you first select a name, but when you change the first combo box, the second one does not update the list... Also when you select the date in the second combo box I receive the error "The Value you have entered isn't valid for this field. You may have entered a text in a numeric field"…. This I do not understand as I have not stipulated any formatting in the combo box.

Any assistance will be greatly appreciated.

Thank you
AK
Oct 10 '07 #1
10 1696
ADezii
8,834 Recognized Expert Expert
Hi

I am hoping someone can help me, I have a form with two combo boxes in it.... The first combo box gets its values from a table via an SQL query in the combo box properties. The second combo box is supposed to get its values also via an SQL query in its properties but it is depending on the result of the first combo box...

ie. First combox has the names of all of the people who have received a document. (This combo box works perfectly well)

The second combo box is to show only the dates the person from the first combo box has received a document. These values come through correctly when you first select a name, but when you change the first combo box, the second one does not update the list... Also when you select the date in the second combo box I receive the error "The Value you have entered isn't valid for this field. You may have entered a text in a numeric field"…. This I do not understand as I have not stipulated any formatting in the combo box.

Any assistance will be greatly appreciated.

Thank you
AK
Refer to this Tutorial for help on the Subject:
Cascading Combo Boxes
Oct 11 '07 #2
AllusiveKitten
43 New Member
Hi,

Thank you so much for your advice it has helped me alot. I have come up with the following coding..

Expand|Select|Wrap|Line Numbers
  1. Private Sub Txt_ProjectOffice_AfterUpdate()
  2.   With Me!Txt_DateSent
  3.     If IsNull(Me!Txt_ProjectOffice) Then
  4.       .RowSource = ""
  5.     Else
  6.       .RowSource = "SELECT Txt_DateSent FROM Tbl_DespactchedDocuments GROUP BY Tbl_DespactchedDocuments.[Project/OfficeName], Tbl_DespactchedDocuments.Date HAVING (((Tbl_DespactchedDocuments.[Project/OfficeName]=[Forms]![FrmEntry_ReceivedTransmittal] '" & Txt_ProjectOffice & "')));"
  7.  
  8.     End If
  9.     Call .Requery
  10.   End With
  11. End Sub
Which is now giving me a syntax error (missing operator) in expression
(((Tbl_Despactc hedDocuments.[Project/OfficeName]=[Forms]![FrmEntry_Receiv edTransmittal] '" & Txt_ProjectOffi ce & "')));"

I have tried a million different ways to no avail, can you see where I am going wrong??

Thank you again for your help
AK
Oct 11 '07 #3
ADezii
8,834 Recognized Expert Expert
Hi,

Thank you so much for your advice it has helped me alot. I have come up with the following coding..

Expand|Select|Wrap|Line Numbers
  1. Private Sub Txt_ProjectOffice_AfterUpdate()
  2.   With Me!Txt_DateSent
  3.     If IsNull(Me!Txt_ProjectOffice) Then
  4.       .RowSource = ""
  5.     Else
  6.       .RowSource = "SELECT Txt_DateSent FROM Tbl_DespactchedDocuments GROUP BY Tbl_DespactchedDocuments.[Project/OfficeName], Tbl_DespactchedDocuments.Date HAVING (((Tbl_DespactchedDocuments.[Project/OfficeName]=[Forms]![FrmEntry_ReceivedTransmittal] '" & Txt_ProjectOffice & "')));"
  7.  
  8.     End If
  9.     Call .Requery
  10.   End With
  11. End Sub
Which is now giving me a syntax error (missing operator) in expression
(((Tbl_Despactc hedDocuments.[Project/OfficeName]=[Forms]![FrmEntry_Receiv edTransmittal] '" & Txt_ProjectOffi ce & "')));"

I have tried a million different ways to no avail, can you see where I am going wrong??

Thank you again for your help
AK
Try:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Txt_ProjectOffice_AfterUpdate()
  2.   With Me!Txt_DateSent
  3.     If IsNull(Me!Txt_ProjectOffice) Then
  4.       .RowSource = ""
  5.     Else
  6.       .RowSource = "SELECT Txt_DateSent FROM Tbl_DespactchedDocuments GROUP BY Tbl_DespactchedDocuments.[Project/OfficeName], Tbl_DespactchedDocuments.Date HAVING Tbl_DespactchedDocuments.[Project/OfficeName]='" & [Forms]![FrmEntry_ReceivedTransmittal] & "' " & "'" & Txt_ProjectOffice & "';"
  7.  
  8.     End If
  9.     Call .Requery
  10.   End With
  11. End Sub
  12.  
Oct 11 '07 #4
AllusiveKitten
43 New Member
Hi ADezii

I have sort of got the combo boxes working together with the following coding:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Txt_ProjectOffice_AfterUpdate()
  2.   With Me!Txt_DateSent
  3.     If IsNull(Me!Txt_ProjectOffice) Then
  4.       .RowSource = ""
  5.     Else
  6.       .RowSource = "SELECT Txt_DateSent FROM Tbl_DespactchedDocuments GROUP BY Tbl_DespactchedDocuments.Date, Tbl_DespactchedDocuments.[Project/OfficeName] HAVING (((Tbl_DespactchedDocuments.[Project/OfficeName])='" & Txt_ProjectOffice & "'));"
  7.  
  8.     End If
  9.     Call .Requery
  10.   End With
  11. End Sub
I have the second combo box bring back the correct number of records, except the actual lines are empty. Do you have any ideas what could be going wrong?

Thank you again
AK
Oct 12 '07 #5
ADezii
8,834 Recognized Expert Expert
Hi ADezii

I have sort of got the combo boxes working together with the following coding:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Txt_ProjectOffice_AfterUpdate()
  2.   With Me!Txt_DateSent
  3.     If IsNull(Me!Txt_ProjectOffice) Then
  4.       .RowSource = ""
  5.     Else
  6.       .RowSource = "SELECT Txt_DateSent FROM Tbl_DespactchedDocuments GROUP BY Tbl_DespactchedDocuments.Date, Tbl_DespactchedDocuments.[Project/OfficeName] HAVING (((Tbl_DespactchedDocuments.[Project/OfficeName])='" & Txt_ProjectOffice & "'));"
  7.  
  8.     End If
  9.     Call .Requery
  10.   End With
  11. End Sub
I have the second combo box bring back the correct number of records, except the actual lines are empty. Do you have any ideas what could be going wrong?

Thank you again
AK
How do you know the correct number of Records are being returned by the 2nd Combo Box if the lines are empty? If you are absolutely sure, check the ColumnWidths Property. A setting of 0 in any Column will hide/make invisible the Column as in: a 4 Column Combo Box with Column Widths of 1";1.5";0";2 " will make the 3rd Column invisible. Also, check the ColumnWidths against the ColumnCount Property, in the above case, ColumnCount should = 4. Let me know how you make out.
Oct 12 '07 #6
AllusiveKitten
43 New Member
Hi again Adezii,

I can see the number of lines in the drop down box, eg if it only one value is returned then there is only one line in the drop down box and if there is 3 values returned there is 3 lines in the drop down etc.

Also there should only be one column returned as I am only calling the Date's, I have checked both the column widths and also expanded it to 4 columns and made the widths large, still this is not working. Is there a way that I can send a copy to you so that you can see rather than me trying to explain it??

And again, thank you for your help
AK
Oct 14 '07 #7
ADezii
8,834 Recognized Expert Expert
Hi again Adezii,

I can see the number of lines in the drop down box, eg if it only one value is returned then there is only one line in the drop down box and if there is 3 values returned there is 3 lines in the drop down etc.

Also there should only be one column returned as I am only calling the Date's, I have checked both the column widths and also expanded it to 4 columns and made the widths large, still this is not working. Is there a way that I can send a copy to you so that you can see rather than me trying to explain it??

And again, thank you for your help
AK
Yes you can. I'll send you my E-Mail address in a Private Message. Reply and send me the Database as an Attachment. Please make sure there is no sensitive data contained within it.
Oct 14 '07 #8
ADezii
8,834 Recognized Expert Expert
AllusiveKitten (love that Name!), I decided to post the possible solution here so that all Members may see it.
  1. Change the Row Source for the TxtProjectOffic e Combo Box to:
    Expand|Select|Wrap|Line Numbers
    1. SELECT DISTINCT Tbl_DespactchedDocuments.[Project/OfficeName] FROM Tbl_DespactchedDocuments WHERE Len([Project/OfficeName])>"0" ORDER BY Tbl_DespactchedDocuments.[Project/OfficeName]; 
  2. Change the code in the AfterUpdate() Event of the TxtProjectOffic e Combo Box to:
    Expand|Select|Wrap|Line Numbers
    1. Private Sub Txt_ProjectOffice_AfterUpdate()
    2. Dim MySQL As String
    3.  
    4. MySQL = "SELECT Distinct [Date] FROM Tbl_DespactchedDocuments WHERE Tbl_DespactchedDocuments.[Project/OfficeName] " _
    5.         & "='" & Me!Txt_ProjectOffice & "' Order by Tbl_DespactchedDocuments.Date;"
    6.  
    7. With Me!Txt_DateSent
    8.   If IsNull(Me!Txt_ProjectOffice) Then
    9.     .RowSource = ""
    10.   Else
    11.     .RowSource = MySQL
    12.   End If
    13.     Call .Requery
    14. End With
    15. End Sub
  3. I think this is what you are looking for, if not just let me know.
Oct 15 '07 #9
AllusiveKitten
43 New Member
AllusiveKitten (love that Name!), I decided to post the possible solution here so that all Members may see it.
  1. Change the Row Source for the TxtProjectOffic e Combo Box to:
    Expand|Select|Wrap|Line Numbers
    1. SELECT DISTINCT Tbl_DespactchedDocuments.[Project/OfficeName] FROM Tbl_DespactchedDocuments WHERE Len([Project/OfficeName])>"0" ORDER BY Tbl_DespactchedDocuments.[Project/OfficeName]; 
  2. Change the code in the AfterUpdate() Event of the TxtProjectOffic e Combo Box to:
    Expand|Select|Wrap|Line Numbers
    1. Private Sub Txt_ProjectOffice_AfterUpdate()
    2. Dim MySQL As String
    3.  
    4. MySQL = "SELECT Distinct [Date] FROM Tbl_DespactchedDocuments WHERE Tbl_DespactchedDocuments.[Project/OfficeName] " _
    5.         & "='" & Me!Txt_ProjectOffice & "' Order by Tbl_DespactchedDocuments.Date;"
    6.  
    7. With Me!Txt_DateSent
    8.   If IsNull(Me!Txt_ProjectOffice) Then
    9.     .RowSource = ""
    10.   Else
    11.     .RowSource = MySQL
    12.   End If
    13.     Call .Requery
    14. End With
    15. End Sub
  3. I think this is what you are looking for, if not just let me know.
Hi ADezii,

You are an absolute treasure, the code works for bringing back the required results, but now I have the problem that the combo box/text box does not like the entry...

"The Value you entered isn't valid for this field"
**For example, you may have entered text in a numeric field or a number that is larger than the FieldSize setting permits.**

I am stumped!!
Oct 16 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

6
2655
by: Greg | last post by:
I am working on a project that will have about 500,000 records in an XML document. This document will need to be queried with XPath, and records will need to be updated. I was thinking about splitting up the XML into several XML documents (perhaps 50,000 per document) to be more efficient but this will make things a lot more complex because the searching needs to go accross all 500,000 records. Can anyone point me to some best practices...
5
2375
by: Shane | last post by:
I wonder if someone has any ideas about the following. I am currently producing some reports for a manufacturing company who work with metal. A finished part can contain multiple sub-parts to make up the finished part. The sub-parts can also be made up of sub-parts and those sub-parts can also be made up of sub-parts etc etc. All parts are contained within the same table and I have a seperate table
2
3061
by: Jeff Barry | last post by:
Hi, I wonder if any one can help, I'm pretty new to Access and I can't figure out how to change the contents of a combo box based on a selection I make in another. Let me explain I have a combo box where I can select a continent from a continent table. I would like the contents of a second combo box to reflect my choice of continent and list countries that are in that continent. These countries are in separate tables/queries (actually...
1
11836
by: meganrobertson22 | last post by:
Hi Everyone- I am trying to use a simple macro to set the value of a combo box on a form, and I can't get it to work. I have a macro with 2 actions: OpenForm and SetValue. I can open my form, but I can't get the macro to set the value of a combo box on the form that opens. I don't need the macro to look up any values, I just want it to set the value of a combo box.
1
2968
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...
7
12275
by: sara | last post by:
I have a form where the user selects an item from a list box, and then works on that item. The user chooses an AD, then opens a form to assign departments to the ad. The top of the Depts form has a combo box, to select an ad from the drop down list. I would like the Depts form to open with the Ad selected on the Main form displaying in the combo box, AND any information already added presented to the user. (I am thinking this latter...
1
2259
by: Jimmy Stewart | last post by:
Is there a way to set up a combo box so that when the user clicks the arrow, the list is populated with info from a specific field from a table but once they select an option, data from another field gets displayed in the box? In other words, when the user selects the drop down list, I want a them to see a list of full titles for them to select. Once they click on a title, however, I want an abbreviation to get put into or displayed in the...
8
2203
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
2634
by: Torilyn73 | last post by:
I posted this earlier... or thought I did... anyway.. it's doesn't appear in the list so I'm reposting it. Can someone please explain to me how to set up the lostfocus event for a combo box. I need the combo to return to its default value when the user clicks away from it ... either somewhere on the form itself or another app. I have no clue how to do this and would really appreciate some help. Thanks!
0
10160
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...
0
10007
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
9951
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
9832
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
8831
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
7378
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
5275
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
5421
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3924
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

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.