Results 1 to 5 of 5
  1. #1
    kiask2343 is offline Novice
    Windows 10 Office 365
    Join Date
    Mar 2020
    Posts
    3

    Default for combobox HELP!!

    I have a large database called main which has a column called exchange_rate. I have a form to input data in this main database called ministry_input. In my ministry_input form there is a combobox name Combo62 which pulls from a table called Exchangerate for the values to be saved in the main database for the record being input. I need the default for the combobox to be the last entry (one with the highest key value) in the Exchangerate table.

    Private Sub Combo62_Click()
    Private Sub Form_Load()
    With Me.Combo62


    .Value = .ItemData(.ListCount - 1)
    End With
    End Sub

    This is what I have the problem is on the form it shows the correct value from the table (the exchange rate with the highest key value) but in the table it puts the key value instead of the value in the "Exchangerate" column. Help plz!

  2. #2
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,557
    Hi

    This is correct because Access stores the Key for the Value you have selected in your Combobox.

    If you want to store the actual value then you need a field in the underlying table into which you can save the value. Call it "Rate" for example.

    Then in the after Update of your "Combo62" you would have this:-

    Me.rate = Me.Combo62.Column(1)

  3. #3
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,530
    IMHO it would be better to only retain the primary key in the table. This is the best way to maintain data integrity. A table is for storing data, not for looking at. A
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  4. #4
    kiask2343 is offline Novice
    Windows 10 Office 365
    Join Date
    Mar 2020
    Posts
    3
    yes it was as simple as changing the bound column to 2 instead of 1, DOH moment if there ever was one. New problem, when I advance to input a new record the combo box is blank rather than giving the newest value in the table. Any help would be very appreciated.

  5. #5
    kiask2343 is offline Novice
    Windows 10 Office 365
    Join Date
    Mar 2020
    Posts
    3
    Solved with this piece of code as the default value.
    =[Combo62].[ItemData]([Combo62].
    [ListCount]-1)

    Thanks

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 02-12-2019, 12:49 PM
  2. Replies: 8
    Last Post: 12-29-2017, 04:19 PM
  3. Subform ComboBox Default Value
    By djrolla in forum Forms
    Replies: 9
    Last Post: 06-24-2014, 12:22 AM
  4. Replies: 3
    Last Post: 06-14-2013, 01:50 PM
  5. Replies: 1
    Last Post: 02-10-2007, 10:21 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums