Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Access Combobox, Value result wrong

Posted on 2016-08-25
5
Medium Priority
?
74 Views
Last Modified: 2016-08-26
Please see the simple database I have included.
The combobox of the included form is unbound and has as its source a simple table with a column named c_name (sorted ascending) and the id column, bound to column 0.
The forms data source is a query based on the table. The querie's criteria is set to a tempvar which holds the comboboxe's column(1) value.
This updates the form with the name and address of the combobox selection. Simple enough.
However, look at the bottom field of the included form. It will show you the combobox value vs the combobox column 1 value...
and they are different! So
This cannot be! Can someone please explain how to fix this problem? I have tried decompiling to no effect.

I inherited a project which has a form directly linked to a table with several comboboxes set up in an identical fashion and they are updating the table with incorrect values. Thank you.
Database9.accdb
0
Comment
Question by:JP_TechGroup
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 1

Author Comment

by:JP_TechGroup
ID: 41770535
This has something to do with the bound column set to 0. Setting it 2 resolves the issue in this context.
0
 
LVL 39

Accepted Solution

by:
PatHartman earned 2000 total points
ID: 41770576
I think your confusion is being caused because the ID is the second column of the query rather than the first.  So column(1) would be numeric.  What I don't understand is why the bound column is registering as numeric rather than text.  But once I changed the column order for the query and adjusted as below, the problem clears up.

Change the order of the selected columns.
Change the bound column to 1 (this is the unique ID for the RowSource - and if the control were bound, it would be the column that would be stored in the RecordSource)
Change the column widths to - 0", 1"
Change the expression that sets the TempVar

TempVars("id") = Me.cmb_id.Value
0
 
LVL 1

Author Comment

by:JP_TechGroup
ID: 41770635
Yes, I actually left the column order as it was and made the bound column 2.
I then set the column count to 1, same result.
0
 
LVL 39

Expert Comment

by:PatHartman
ID: 41770712
Sometimes you can get away with doing things like lying about the column count.  Other times you get bit.  Best to stick to standard methods and avoid potential issues and the confusion you cause people who must work on the app after yourself.  Good practice is "good" for a reason.
0
 
LVL 1

Author Comment

by:JP_TechGroup
ID: 41771647
Agreed. Thanks
0

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question