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 John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Msgbox with a combo box in it? How make it? 2

Status
Not open for further replies.

RSX02

Programmer
May 15, 2003
467
CA
Hi
I would like to do a msgbox with a combo box in it that the user can choose a item in it and click ok to return it to the form. I know that it have a input box but it is not exacly what I want as I want a combo box instead the text box...
First:
How can I create a msgbox like it?
SEcond:
How can I insert value in it that come from a recordset?
third:
How can I return the value that the user entered?

Thanks in advance
 
You could just put a combobox and a command button on a small form and call it modally, sending the result to a public variable in the calling form.

To fill the combo get your recordset and loop through the rst using the AddItem method on the combobox:
(snippet only):

strSQL = "Select fldName, fldID from tblNames"
Set rst = cn.Execute(strSQL)
With rst
Do While Not .EOF
myCount = myCount + 1
myCombo.AddItem .Fields(0)
myCombo.ItemData(myCount) = .Fields(1)
.MoveNext
Loop
End If
End With


________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'
 
I'm almost sure that you cannot add a combo to a standard message box.

What I would suggest is to create a form, make it look nice (Like a msgbox), put on the controls that you need.

When you need to use it, call it like frmMessage.Show vbModal

This will give it the "you have to close me in order to return to your form" feel, like a message box.

You can then pass values from it to your original form like

frmOriginalform.Text1 = combo1.text

and then unload your frmMessage form



**********************************
May the Code Be With You...
----------
x50-8 (X Fifty Eigt)
 
x508
Pretty nice Idea...I'm gonna try this and let you know how it goes. But I'm sure that it gonna work

Thanks to both of you
 
You're welcome! (I think you'll find that the 2 solutions are the same!)

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'
 
NP.

It will work, cause I actually did it before I knew that I could use the MsgBox Function.....lol (a long long time ago)

**********************************
May the Code Be With You...
----------
x50-8 (X Fifty Eigt)
 
it's gonna work.
Sorry John...I didn't read your message as I should...I guess that I read too fast :)
Thanks!
 
You're welcome, and thank you!

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top