Results 1 to 12 of 12
  1. #1
    KingOf206 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2013
    Location
    Seattle
    Posts
    153

    How to keep a default value in a combo box when entering records.

    I have created a very basic form for Data entry.

    I have a combo box in which I have the users names for data entry. Ideally I would like them to select their name using the combo box, and then fill out the remaining fields, then once they click the "save Button" and go to a new record, it will keep their username (which will be in the "Entered by" combo box) as the default when going to a new record.

    I have searched this online and have found a few SQL codes but none of them seem to work.

    Is there a simple way I can get the combo box "entered By" to stay as the default as the user is entering in new records?

    If I need to post any other pics or other information please let me know.Click image for larger version. 

Name:	Untitled.png 
Views:	5 
Size:	41.3 KB 
ID:	21346

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    SQL is not what you need. This requires a VBA solution. You want to carry forward the EnteredBy value to another record - one way is code in the combobox AfterUpdate event to set its DefaultValue property. How does user move to a new record? Is there code in the SAVE button doing that?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    KingOf206 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2013
    Location
    Seattle
    Posts
    153
    The user moves to the NExt record by clicking on the green "SAVE" button. RIght now there is no code in the save button. THe save button only saves the record and moves on to a new record. Someone gave me some code before which was this:

    Private Sub Combo16_AfterUpdate()
    Me.Combo16.DefaultValue = Me.Combo16


    End Sub


    in the AfterUpdate i changed to "event procedures" then I tossed the code (above) in there. It still does not work.

    What else can I try?

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    That code should do it. What does 'does not work' mean - error message, wrong results, nothing happens?

    The combobox will not populate with the default value until record is initiated by data input to some other control.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    KingOf206 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2013
    Location
    Seattle
    Posts
    153
    nothing happens. I enter in a record, and then when I click save it goes to the next record but i still have to use the drop down combo box to select my user name again.

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    I edited my earlier post. Perhaps you missed the additional comment about entering data into another control.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    KingOf206 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2013
    Location
    Seattle
    Posts
    153
    I am not sure what you mean by "entering data into another control" can you please clarify this?

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    A default value is not triggered until record is initiated. Record is initiated when data is entered (typed or otherwise selected by user) in a field or control. So enter some other data into another control (maybe the Tray_number) and see what happens in the EnteredBy combobox.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  9. #9
    KingOf206 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2013
    Location
    Seattle
    Posts
    153
    oh yeah... My testing has included that aspect. That is why I am confused at why it doesn't work. When testing this form out i do enter data in all fields that you see about in my attached pic of the form. But still it doesnt work.

    Here are more screen shots to show what I am doing:

    Here is a pic of design view. I have the "entered by combo box selected" and then on the afterupdate i change to "event procedures" then I click the "..."
    Click image for larger version. 

Name:	Untitled.jpg 
Views:	7 
Size:	155.4 KB 
ID:	21347

    Once i click the "..."
    it takes me where I can put the code in which is here (this shows me where I am using the code):

    Click image for larger version. 

Name:	Untitled1.png 
Views:	7 
Size:	109.1 KB 
ID:	21348


    You told me that the code I have should work. But its not. Nothing happens at all, I still have to choose the "entered by" field every time, its not saving the last one I used as a default.

    What in the world am I getting wrong? I know i am missing something....

  10. #10
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    What is the data type of TrayEnteredBy - number or text? If it is text:

    Me.Combo16.DefaultValue = "'" & Me.Combo16 & "'"

    This works for me.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  11. #11
    KingOf206 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2013
    Location
    Seattle
    Posts
    153
    Holy Crap. That was it! That was Friggin it! LOL Thank you. You just saved a ton of keystrokes! Thanks June7

  12. #12
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    I had expected TrayEnteredBy to be number type for a user ID, not text, so did not think of that immediately.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Entering new information in a combo box
    By craigugoretz in forum Forms
    Replies: 1
    Last Post: 02-07-2015, 05:44 PM
  2. Entering records by using calendar
    By wnicole in forum Access
    Replies: 3
    Last Post: 10-02-2013, 07:47 AM
  3. Update Combo Box after entering new info
    By justgeig in forum Programming
    Replies: 13
    Last Post: 06-07-2012, 04:24 PM
  4. entering new records
    By MissRyan in forum Access
    Replies: 6
    Last Post: 06-29-2011, 04:39 AM
  5. Entering Text in Combo Form
    By Bobt in forum Forms
    Replies: 2
    Last Post: 10-22-2010, 03:53 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