• Combo Box Default value (Access97)

    Author
    Topic
    #359509

    I have a combo box of States and their abbreviation. I want it to set a default value. When I do this with the Me!ComboBox = Me!ComboBox.itemdata(xx) it changes the selection in records previously recorded.

    How do I get a default value that will not affect the already existing records.

    Soc

    Viewing 1 reply thread
    Author
    Replies
    • #538989

      It seems that instead of setting a default value, your code is actually assigning a value to the combo box.

      In the Properties Window for the Combo Box, on the Data tab, there is a Default Value row. Have you tried entering your value there? Or, via code try, Me![ComboBox].DefaultValue = your default value.

      • #539024

        Hi, Sorry for not being clear. I had the code you suggested in the “on got Focus” event. It did not work as it was changing data in already established records. I also tried the default value on the data tab but that did not seem to work. It did enter value in the table but left the form field empty.

        I think the other suggestion by another person will work. I am supposed to put the code in the “after update” event of the current record. I’ll try that. thanks for the help.

        Soc

    • #538995

      >>Me!ComboBox = Me!ComboBox.itemdata(xx)<<

      Just where in the above statement are you changing the DefaultValue? I bet you are putting this in your form's Current event. This code changed the actual value of the combo box each time that line became current. If you were on a new record, you mistook it for the DefaultValue, but actually it just become the first entry.

      Exactly where it the situation here. Usually, you should be setting the DefaultValue in some other event (such as the AfterUpdate of the last NewRecord enterred), so that the next time a NewRecord is displayed, it will have the correct default value.

      • #539023

        Hi’
        Good point. I was putting the code in the combo box “got focus”. I think you hit it though. I should put the code in “after update” for the record. I’ll try that. Thanks.
        Soc

    Viewing 1 reply thread
    Reply To: Combo Box Default value (Access97)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: