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

Posted on 2011-10-02
Last Modified: 2012-05-12
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
Question by:JohnSaint
    LVL 56

    Assisted Solution

    by:Jim Dettman (Microsoft MVP/ EE MVE)

     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:




      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.


    Author Comment

    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.
    LVL 61

    Accepted Solution

    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

    Author Comment

    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...

    Author Closing Comment


    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Join & Write a Comment

    This isn't a frequent question on EE. I must have seen it three or four times (among several thousand questions). However, I use this trick quite often, most frequently as a delayed Current event. A form does not expose it's calculation dependenc…
    Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
    Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

    746 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

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now