Printable Version of Topic

Click here to view this topic in its original format

UtterAccess Forums _ Access Q and A _ Inputbox Is Not Quite Sufficient

Posted by: JohnvanSomeren Dec 7 2017, 12:01 PM

How do I write my own InputBox form which waits on the user?

In my system all ussers are logged on during the Open event of the Main Menu form. No user input was required until now. Now I want the users to select which branch they are working on during that session.

There is no form open at this time (the main menu hasn't displayed yet) and I could, if pushed, code this:

CODE
    If HomeBranch = "??" then
        strCurrentBranch = InputBox "What Branch ID?"
        '[add validation code here]
    else
        strCurrentBranch = HomeBranch
    end if

However I want users to select from a combo box. I built a form with only the combo box and an OK button. The OK button updated tblUsers with the selected current branch.

My code now says
CODE
    If HomeBranch = "??" then
        docmd.OpenForm "frmChangeBranch"
    else
        strCurrentBranch = HomeBranch
    end if


I honestly did not know that Access would not wait on the open form. It doesn't: it just opens the window and passes on to all the commands right down to the end sub.

Posted by: theDBguy Dec 7 2017, 12:02 PM

Hi,

Try adding the acDialog argument to your OpenForm method.

Hope it helps...

Posted by: JohnvanSomeren Dec 7 2017, 12:19 PM

Got it. 100% solved. It's been a long time since I've seen your signature on a reply to one of my problems, but you are still hitting gold. Many thanks.


 

Posted by: theDBguy Dec 7 2017, 12:29 PM

Hi John,

You're welcome and thanks. Good luck with your project.