How do I set an initial combo box value when the source table is linked

Hi all,

I have a combo box which looks up employee names in a table. I would like to set the initial value of the combo (depending on which employee is using the system) on opening the form.

This is straightforward I know; me.combobox = "whoever"

I notice, however, that when I split the database, the combo box still works fine but no longer allows me to set an initial value. I could have sworn I have done this before with success. I am very confused...

Thanks in advance, John
JohnSaintAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jim Dettman (Microsoft MVP/ EE MVE)President / OwnerCommented:
John,

 There's no reason it should stop doing that unless you have limit to list set to yes and your default value is not in the table.

 A better approach is to use this:

=Forms![<myFormName>]![<myComboControName>].ItemData(0)

or

=Forms![<myFormName>]![<myComboControName>].ItemData(1)

  If you have column headings set to yes.

  This will default the combo to the first entry in the list if there is any data.

  Note: make sure you replace   "<myFormName>" and "<myComboControName>"  with your actual form and combo names.

Jim.
0
JohnSaintAuthor Commented:
It's odd.

I literally created the combo. It worked fine and set the default.

I split it and it stopped defaulting.

Try it yourself. I've attached the pre-split db. It works fine.
Spilt it and it loses the default.

I appreciate it if you don't want to but I'd be interested to see if you get the same results. Otherwise I will try your suggestions.
SplitDrop.accdb
0
mbizupCommented:
Jim's right about the Limit to List property.

Explaining what you are doing...

Your combo box is bound to the ID field in your table.  The IDs in your combobox define what the value is.

You are setting it to "John", which is not a valid ID.

If you set it to 1 (John's ID), which is in the list of IDs, it will work either in a split or non-split DB.

I am very surprised that setting the value of the combo to "John" worked at all.  I didn't know that was doable.

All that said, the method that Jim described above is my preferred method as well
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
JohnSaintAuthor Commented:
Hi Guys,

Jim, I don't want to default to the first item in the list, I want to set it to a specific value which will change depending on who logs in. That is a nice tip though, cheers.

Mbizup, you cracked it. It shouldn't really have let me do it in the first place and that was what stumped me. I can either set the initail value to the correct ID value or I can remove the ID select from the combo and just select on the Employee names. Both seem to work.

Jim, I'll have to give more points to Mbizup here but many thanks to you both. Great work again...
0
JohnSaintAuthor Commented:
Thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.