Results 1 to 11 of 11
  1. #1
    Poppy is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2018
    Location
    Southampton England UK
    Posts
    3

    Multi Valued Fields


    Does anyone know what vba code I need to use in order to move focus from a combo box to another control? The usual .setfocus method isnt working because the combo box is bound to a Multi Valued field. I receive the RunTime Error 2110. The control I am trying to move to is just a simple text box that is enabled and is visible so it has nothing to do with the text box control and is definitely the MVF combo box.

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    Can you show us the code that produces the error or better still, post a copy of your db
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    I don't use MVFs but just did test. Get the same issue with AfterUpdate event. What other events have you tried?
    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.

  4. #4
    isladogs's Avatar
    isladogs is offline Access MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,204
    I also don't use MVFs and also did a test to move the focus back to the previous control

    This does cause error 2110 as stated
    Code:
    Private Sub MVF_AfterUpdate()    
    Me.ID.SetFocus
    End Sub
    but this runs without error & worked for me
    Code:
    Private Sub MVF_LostFocus()
    Me.ID.SetFocus
    End Sub
    I clicked Enter to move the focus away from the MVF

    Even so, another good reason for avoiding MVFs - see this article on my website http://www.mendipdatasystems.co.uk/m...lds/4594468763
    Colin Riddington, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I know I don't know, I keep quiet!

  5. #5
    Poppy is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2018
    Location
    Southampton England UK
    Posts
    3

    Lightbulb Sample db attached

    Quote Originally Posted by Bob Fitz View Post
    Can you show us the code that produces the error or better still, post a copy of your db
    Hi Bob

    Attached is a very simple example of what I am trying to achieve (sorry couldnt send my entire db but this one still demonstrates the issue).

    Open the database and then on the form which opens just click on the drop down and select one (or more) of the options by ticking the boxes and then click OK. The code behind the after update event simply moves the focus to the next control using the .setfocus method but when doing this it produces the 2110 error.

    Hope you can help

    thanks
    Poppy
    MulitValuedCombo.zip

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    I say let user learn to press Enter or Tab to move to next control, same as with other controls.
    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
    isladogs's Avatar
    isladogs is offline Access MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,204
    Poppy
    Have you tried my suggestion in post 4? Works for me
    Colin Riddington, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I know I don't know, I keep quiet!

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    That code requires pressing Enter key or clicking elsewhere for combobox to lose focus. Pressing enter will just take user to the next control without any code, which appears to be what the OP wants to accomplish - move to next 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.

  9. #9
    isladogs's Avatar
    isladogs is offline Access MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,204
    The way the original question was worded indicated the OP wanted to move to a specific control rather than the next one in the tab order.
    That was my reason for suggesting that solution.
    Colin Riddington, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I know I don't know, I keep quiet!

  10. #10
    Poppy is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2018
    Location
    Southampton England UK
    Posts
    3
    Just to clarify a little.
    After selecting the options in the MFV combo box and then clicking on OK triggers the after update event which is what I want. Part of the code of that after update event is to move the control to a specific control. This is defined by what the user has selected and therefore maybe different each time. So I dont want the user to go to the 'Next' control but a specific one. I have some conditions in my code which work but its the .setfocus that doesnt. I am sure it has something to do with the OK button having the focus and not being able to move focus from it.

    Thanks everyone for their input, I really appreciate it. I understand about not using MVF but this is an inherited db which I am developing and dont have loads of time to redesign it.

  11. #11
    isladogs's Avatar
    isladogs is offline Access MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,204
    So as I suggested, I think you will need to move your code to the lost focus event.
    I suppose you could use SendKeys to click Enter automatically in the after update event but I wouldn't recommend that.
    Colin Riddington, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I know I don't know, I keep quiet!

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

Similar Threads

  1. Multi-valued list
    By TMac in forum Access
    Replies: 5
    Last Post: 09-24-2018, 05:14 PM
  2. Replies: 4
    Last Post: 06-12-2018, 06:22 AM
  3. Append Query - Multi-Valued Fields
    By lynthel in forum Queries
    Replies: 8
    Last Post: 08-03-2017, 11:46 AM
  4. Multi Valued field sort
    By bugman61 in forum Reports
    Replies: 2
    Last Post: 08-06-2011, 11:45 AM
  5. querying Multi-valued fields
    By switters in forum Queries
    Replies: 1
    Last Post: 04-21-2011, 10:59 AM

Tags for this Thread

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