Results 1 to 4 of 4
  1. #1
    lefty2cox is offline Competent Performer
    Windows 7 64bit Access 2016
    Join Date
    May 2013
    Posts
    163

    Not in list for unbound combo box

    I have a form with a combo box that is unbound. The form itself is bound to myTable The row source for the myCombo is a select statement based on the same, mytable.

    When you select an item in the list, the form populates with the record using a macro on the after update event.

    I was trying to write code for the not in list event that would advance the form to a new record and then place the NewData into the proper field as I have a bound text box to the same field that is the row source of the combo box.

    This set up seems to be causing a problem. I'm using docmd.gotorecord to try and add a new record but it gives me an error: Run-Time error '2105'. You can't go to the specified record. I think it's because mycombo is unbound.

    Should I try another way or can this actually be done? If it can, I'll keep working at it.

    Thanks.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    Yes, should be possible. Post your attempted code.
    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
    lefty2cox is offline Competent Performer
    Windows 7 64bit Access 2016
    Join Date
    May 2013
    Posts
    163
    I kept at it and sorted it out. Thank you very much. I think I was stuck in a weird loop. I think that the not in list event would fire and then I was trying to add a new record but hadn't cleared the requirement of the not in list event, which needed to be resolved before I could move on to adding a record. I simply set the value of mycombo to "" after storing NewData in a variable. This allowed me to then move to a new record and proceed from there. Thanks again for quickly responding.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    Advise instead of setting combo to empty string, use Null or mycomb.Undo. I don't like dealing with empty strings if I can help it.

    Don't really have to store NewData in a variable. NewData is a variable. Consider example:

    Private Sub Combo51_NotInList(NewData As String, Response As Integer)
    Response = acDataErrContinue
    Me.Combo51.Undo
    DoCmd.GoToRecord , , acNewRec
    Debug.Print NewData
    End Sub
    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. Replies: 6
    Last Post: 04-15-2019, 09:03 PM
  2. Replies: 5
    Last Post: 01-07-2019, 01:51 AM
  3. Color Coding on an Unbound List Box
    By JustTrying in forum Forms
    Replies: 2
    Last Post: 12-24-2014, 08:21 AM
  4. Replies: 9
    Last Post: 11-06-2014, 01:15 PM
  5. Unbound list box
    By waseemthonse in forum Forms
    Replies: 1
    Last Post: 11-02-2010, 07:36 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