473,405 Members | 2,287 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,405 software developers and data experts.

Combo box selection gives wrong record - strange

BigToe
11
Hello, if anyone out there can shed light on the fact that when a last name is selected in a combo box, and that name is shared by more than one person, why access is displaying the first record in the list of like names. (i.e. when choosing 'zach smith' , 'andy smith's record will be shown. I assume that it's sorting by first names when last names are the same that doesn't explain why it always shows the record of the first person amoung a group with the same last name when another person is selected within that group. any ideas?
Sep 25 '07 #1
13 8414
Scott Price
1,384 Expert 1GB
Hello, if anyone out there can shed light on the fact that when a last name is selected in a combo box, and that name is shared by more than one person, why access is displaying the first record in the list of like names. (i.e. when choosing 'zach smith' , 'andy smith's record will be shown. I assume that it's sorting by first names when last names are the same that doesn't explain why it always shows the record of the first person amoung a group with the same last name when another person is selected within that group. any ideas?
What is the RowSource and table structure for your combobox?

Regards,
Scott
Sep 25 '07 #2
BigToe
11
What is the RowSource and table structure for your combobox?

Regards,
Scott

Scott,
the rowsource is a querry. the row source type is 'Table/Querry'. the sql for that querry looks like this:

SELECT [Clients].[Last Name], [Clients].[First Name]
FROM Clients
WHERE ((([Clients].[Service Coordinator])=[Forms]![recall client stats]![cboSC])) Or ((([Clients].[Waitlist Region])=[forms]![recall client stats]![cbowaitlist]));

I hope that answers your question.
thanks
tony
Sep 26 '07 #3
Scott Price
1,384 Expert 1GB
Scott,
the rowsource is a querry. the row source type is 'Table/Querry'. the sql for that querry looks like this:

SELECT [Clients].[Last Name], [Clients].[First Name]
FROM Clients
WHERE ((([Clients].[Service Coordinator])=[Forms]![recall client stats]![cboSC])) Or ((([Clients].[Waitlist Region])=[forms]![recall client stats]![cbowaitlist]));

I hope that answers your question.
thanks
tony
Hi Tony,

The problem is probably showing up because you aren't using a unique field as a 'control field' in your query. I'm assuming that in your combo box the bound column is the default of 1. This means that the value returned by the combo box choice will be the value from column 1, which in your case is the last name, and being as the last name field contains duplicates, the first of those is being used.

Add your ClientID field into the query as the first item in your select statement, and make sure the bound column is set to 1.

Regards,
Scott
Sep 26 '07 #4
BigToe
11
Hi Tony,

The problem is probably showing up because you aren't using a unique field as a 'control field' in your query. I'm assuming that in your combo box the bound column is the default of 1. This means that the value returned by the combo box choice will be the value from column 1, which in your case is the last name, and being as the last name field contains duplicates, the first of those is being used.

Add your ClientID field into the query as the first item in your select statement, and make sure the bound column is set to 1.

Regards,
Scott

thanks for your patience Scott but this is still not working. I placed the ClientID field first in the sql statement, set the bound column to 1 (it was already) and a). after choosing a name in the combo box the hourglass just hung for about 10 sec. and nothing happened (i.e the record for that client did not show) and b). the ClientID number now appears in the combo box. when i deselect 'show' in the querry builder it deletes the ClientID field in the sql statement all together! is that normal? here's my new sql statement:

SELECT [Clients].[ClientID], [Clients].[Last Name], [Clients].[First Name]
FROM Clients;
Tony
Sep 26 '07 #5
missinglinq
3,532 Expert 2GB
I solved this problem by adding a calculated field in my query, then basing the combobox on the calculated field. In a new field in query design, under the field name enter something like

WholeClientName: [LastName] & " " & [FirstName]

then run the Combobox Wizard and select WholeClientName as the field to pull on.

Welcome to TheScripts!

Linq ;0)>
Sep 26 '07 #6
Scott Price
1,384 Expert 1GB
thanks for your patience Scott but this is still not working. I placed the ClientID field first in the sql statement, set the bound column to 1 (it was already) and a). after choosing a name in the combo box the hourglass just hung for about 10 sec. and nothing happened (i.e the record for that client did not show) and b). the ClientID number now appears in the combo box. when i deselect 'show' in the querry builder it deletes the ClientID field in the sql statement all together! is that normal? here's my new sql statement:

SELECT [Clients].[ClientID], [Clients].[Last Name], [Clients].[First Name]
FROM Clients;
Tony
Take a good look at Linq's suggestion! Also, whenever you have multiple columns in a combo box, and the first column is an ID number field, make sure that the column widths are set to 0", 1.5" (or whatever width needed to display the data), etc...

As for the problem of the db 'hanging' for 10 sec, what field is the combo box bound to? Now that the bound column is an ID field, the bound field needs to be an ID field also!

At the risk of sounding patronizing, please also make sure that you have compiled, saved, backed up, and compacted/repaired your database (in that order). When developing (I'm sure you know this, but never hurts to say it again...) this process should be done at least once a day, and the compile/save every time you make a change in your code window.

Regards,
Scott
Sep 27 '07 #7
BigToe
11
Take a good look at Linq's suggestion! Also, whenever you have multiple columns in a combo box, and the first column is an ID number field, make sure that the column widths are set to 0", 1.5" (or whatever width needed to display the data), etc...

As for the problem of the db 'hanging' for 10 sec, what field is the combo box bound to? Now that the bound column is an ID field, the bound field needs to be an ID field also!

At the risk of sounding patronizing, please also make sure that you have compiled, saved, backed up, and compacted/repaired your database (in that order). When developing (I'm sure you know this, but never hurts to say it again...) this process should be done at least once a day, and the compile/save every time you make a change in your code window.

Regards,
Scott
Good reminders Scott - thank you. I figured out the spacing of the columns and place the ClientID column first (already set to autonumbers). I also have set the bound column to the first column (clientID). because I have never created a calculated field before I will give that a go tomorrow and let you all know the results.
cheers,
Tony
Sep 27 '07 #8
BigToe
11
Gentlemen, this seems like an exercise in futility. I hope you have the patience to endure another question. I successfully created a calculated field (which I think are extremely cool btw) but my vba code for that combo box doesn't seem to like the new format, i.e. records to not change when a name is selected from the combo box. Unless i'm missing something obvious, I can only assume that there's something inherently wrong with my form. I've removed the calculated field and there is no change. the querry that I once had working no longer works. I have saved and compacted/repaired with no luck. the vba code for that combo box is still the same (Clientstemp is the subform):

Expand|Select|Wrap|Line Numbers
  1. Private Sub cboClients_AfterUpdate()
  2.     'Moves to client Name text box and
  3.     'finds the record of whatever name is selected in the combo box
  4.  
  5.     DoCmd.ShowAllRecords
  6.     Me!Clientstemp.SetFocus
  7.     DoCmd.FindRecord Me!cboClients
  8.  
  9.     'just moves the highlighted cursor away from the Last Name after selection is made
  10.     DoCmd.GoToControl "middle name"
  11.  
  12.     'Set value of combo box equal to an empty string
  13.     Me!cboClients.Value = ""
  14.  
  15. End Sub
The form i have created has 3 combo boxes in the header and a subform in the body (below the header). This subform was created with the forms wizard and saved as a form; then imported into this form as a subform.The first and last name text boxes are in the subform with all the other client information broken up under tabs (or pages). This may be extraneous information but if anyone can see a connection to the way this form is set up to the lack of control I have with calling up a record please reveal it to me! I'd be willing to start from scratch if it meant a smoother process for building this database.
thanks again,
Tony
Oct 3 '07 #9
Scott Price
1,384 Expert 1GB
Hi, Tony!

You shouldn't need to start from scratch (at least not yet :-)

When referring to subforms the correct syntax is Forms![MainFormName]![SubFormName].Form![ControlName].

I see in your code you are trying to refer to the subform like this: Me![Subformname]![ComboboxName].

Change this over and see what happens.

Regards,
Scott
Oct 4 '07 #10
BigToe
11
Hi, Tony!

You shouldn't need to start from scratch (at least not yet :-)

When referring to subforms the correct syntax is Forms![MainFormName]![SubFormName].Form![ControlName].

I see in your code you are trying to refer to the subform like this: Me![Subformname]![ComboboxName].

Change this over and see what happens.

Regards,
Scott
Hi Scott,
I feel that I'm so close in getting this! This last bit of info was highly interesting. I found this site to compliment what you said:
[HTML]http://www.mvps.org/access/forms/frm0031.htm[/HTML]

there is a glitch that I can't seem to solve. here is my code again:

Expand|Select|Wrap|Line Numbers
  1. Private Sub cboClients_AfterUpdate()
  2.     'Moves to client Name text box and
  3.     'finds the record of whatever name is selected in the combo box
  4.  
  5.     DoCmd.ShowAllRecords
  6.     Forms![recall client stats]![Clientstemp].Form![cboClients].SetFocus
  7.     DoCmd.FindRecord Me!cboClients
  8.  
  9.     'just moves the highlighted cursor away from the Last Name after selection is made
  10.     'DoCmd.GoToControl "middle name"
  11.  
  12.     'Set value of combo box equal to an empty string
  13.     'Me!cboClients.Value = ""
  14.  
  15. End Sub
the runtime error 2465 (stops on line 6) states that access can't find the field 'cboClients'. If it makes it any clearer, cboClients exists in the parent form and the record text boxes and info etc. exists in the sub form. I've tried different variations of what you suggested but nothing has worked so far. any ideas?
Tony
Oct 4 '07 #11
Scott Price
1,384 Expert 1GB
I think in line 6 you want it to find and setfocus to the text box, don't you?

Regards,
Scott
Oct 4 '07 #12
BigToe
11
I think in line 6 you want it to find and setfocus to the text box, don't you?

Regards,
Scott

Expand|Select|Wrap|Line Numbers
  1. Private Sub SuccessIsSweet_AfterMuchFrustration
  2. Dim firstBorn as String
  3.  
  4. firstBorn = "Scott"
  5.  
  6. doCmd.Offspring
  7. If Me.AfterUpdate = True Then
  8. Forms![Hospital].Form![First Name].firstBorn
  9.  
  10. Else: doCmd.keepTrying!
  11.  
  12. end If
  13. end Sub
thanks buddy!
Oct 4 '07 #13
Scott Price
1,384 Expert 1GB
I take it that means you solved it??!

Made me laugh :-) LOL

Regards,
Scott
Oct 5 '07 #14

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

Similar topics

1
by: Alex | last post by:
Acc97.. I have a database which records down-time on 8 machines, the selection of reasons comes from a combo box. I have tried to be clever! and limit the options relative to each machine within...
1
by: Mark Lees | last post by:
I would like to use a combobox that looks up values. For example, I want my users to be able to select a client's last name from a combobox and then by selecting the client's last name all of...
3
by: J | last post by:
I've moved the database tables from the .mdb file to Sql Svr and now I have an *intermittent* problem. When I select a record from a combo box, it will intermittently pull up the wrong record. ...
7
by: ShyGuy | last post by:
I have a form with a combo box for last name. It shows the record with whatever name I select in the combo box. I am trying to get the same results with code when I open the form by using a value...
0
by: paulquinlan100 | last post by:
Hi I have a combo-box which is filled with values from a query with the current record ID as a parameter. This all works fine, except the combobox always starts with a blank record so at first...
1
by: kevvan | last post by:
I have a form that presents a user with a dropdown populated with a user name. The drop down control is bound to two things in a user table, the USERNAME and a related USERID. The drop down control...
3
by: zufie | last post by:
How can I get the Value that I select using my Combo Box to be UNIQUE (to save to ONE record)to the respective Record that I am viewing on my Form? At present, when I select a Value from the...
3
by: dblack64 | last post by:
I am working in Access 2007. I have a form named Master Terms List that contains 4 bound text boxes and 7 cascading combo boxes. The bound text boxes have data sources from a table named Termslist. ...
4
by: dekk | last post by:
I am trying to populate a text field from the combo selection. I have the following update event in the combo box Private Sub cboContract_AfterUpdate() Me!txtDesc = Me!cboContract.Column(1)...
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: 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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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,...
0
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...

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.