Results 1 to 6 of 6
  1. #1
    dark1500 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jan 2014
    Location
    Slovakia
    Posts
    3

    Save/Lock the selection in selectbox

    Hello all,
    I would like to describe the situation where I need your help.

    I have a form where I use selectbox where data are called from a table.


    So lets say I have selected an option from this selectbox and fulfill other object and going to add next new entry but the selection of the selectbox has been reseted.
    I need to reach to do not reset the selectbox to default when Im creating next new database entry.

    Thank you for help.

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    If you are moving to a new record and this is causing your combobox to change to a default value, consider not binding your combobox to a control source. If the combobox operates independently you do not need to worry about the form forcing change. You can use code to update the appropriate field using the combobox's afterupdate event.

  3. #3
    dark1500 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jan 2014
    Location
    Slovakia
    Posts
    3
    Quote Originally Posted by ItsMe View Post
    If you are moving to a new record and this is causing your combobox to change to a default value, consider not binding your combobox to a control source. If the combobox operates independently you do not need to worry about the form forcing change. You can use code to update the appropriate field using the combobox's afterupdate event.
    Thank you for reply,
    Can you show me how would you do it? I have no idea how to write the procedure for this purpose. I would appreciate it!

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    In the combobox's properties clear the value in the Control Source field. This is what associates the combobox with a control on the form. Also, make sure the combobox's default value is cleared.

    With that, you will need to use some VBA to assign the combobox's value to a field in a table or a control on a form.

    Set the property of the combobx's bound column. You will want to bind the column that contains the data you want to use to populate your associated field/control. In most cases this should be a primary key value, perhaps the first column. Type '1' in the combobox's Bound Column field to bind the first column.

    Now the value of the combobox will be that of the bound column and the selected row.
    Bound Column = Me.Combobox.Value

    So you can use the Comboox's AfterUpdate event to populate a field

    Me.ControlName.Value = Me.Combobox.Value

  5. #5
    dark1500 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jan 2014
    Location
    Slovakia
    Posts
    3
    Hello,
    Sorry for the late reply but as first let me say a thanks for your post. I have tried what you have written here, so now the combobox is saving the value as I wanted, but still not saving the value to the table to which the form belongs.

    So this is what Im facing to that even I can set the value of combobox to be the same at every new entry, the value of the combobox is not transfered to the table where all other data does.

  6. #6
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    A combobox is a good tool for user input. The user selects a value from the available values in the combo. This user interaction changes the value of the combobox. What you do with the value is up to you. One option is to use VBA in the AfterUpdate event handler of the combobox. Another option is to connect a control to the combo by placing the name of the control in the combobox's Control Source.

    If the control name you place in the combobox's Control Source is a bound control, the corresponding field in the table will be populated with the value of the combo.

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

Similar Threads

  1. Replies: 1
    Last Post: 12-09-2012, 07:11 AM
  2. Replies: 3
    Last Post: 10-08-2012, 08:40 AM
  3. Replies: 8
    Last Post: 09-27-2012, 11:12 AM
  4. Replies: 1
    Last Post: 07-18-2011, 03:08 AM
  5. Replies: 9
    Last Post: 01-20-2011, 02:22 PM

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