Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

can I create a message box with a combo input field?

Status
Not open for further replies.

timotai

Technical User
Apr 13, 2002
119
GB
Hi

I want to create a message box which provides contains combo box for the users to select the value they want and then proceed and this value will need to be used later on in the coding.

firstly is this possible?

If it is then how?

If not what are the alternatives?

All help and advise is greatly appreciated

Many Thanks

Tim

 
I think you mean an InputBox.

In any case, it's very possible.

1) Create an 'unbound' form (one that is not associated with a table).

2) Set the form properties so that it looks like a popup dialog (e.g. turn off navigation buttons, record selectors)

3) Add a combo box to the form. The wizard will help you define the values. I would suggest that you first create a table with the values that you wish to populate the combo box with.

4) In the Form_Close event, store the current value of the combo box in a global variable, or perhaps a container of global items. You can create a module with non-public items, and add get and set routines...
e.g.

Dim CurrentColor as string

sub SetCurrentColor(ToWhat as string)
CurrentColor= towhat
end sub

function GetCurrentColor() as string
GetCurrentColor = CurrentColor
end function

thus, in the form close
SetCurrentColor(me.MyCombo)


and, in the code that uses the combo value
dim MyVar as string
MyVar = GetCurrentColor.

you can even write a function to do all this:

(note: I likely have the wrong number of ','s preceeding acdialog)

function GetColorFromUser() as string
docmd.openform "GetColorForm",,,,,acdialog
GetColorFromUser = GetCurrentColor
end function

HTH
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top