Results 1 to 6 of 6
  1. #1
    Lounger
    Join Date
    May 2003
    Location
    London, Gtr London, England
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Combo Box Default value (Access97)

    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

  2. #2
    3 Star Lounger
    Join Date
    Dec 2000
    Location
    USA
    Posts
    379
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Combo Box Default value (Access97)

    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.

  3. #3
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Combo Box Default value (Access97)

    >>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.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  4. #4
    Lounger
    Join Date
    May 2003
    Location
    London, Gtr London, England
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Combo Box Default value (Access97)

    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

  5. #5
    Lounger
    Join Date
    May 2003
    Location
    London, Gtr London, England
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Combo Box Default value (Access97)

    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

  6. #6
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Combo Box Default value (Access97)

    But make sure you use "mycombox.DefaultValue = ....."!
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •