Customized Inputbox

D

Dan

You know when you call a inputbox in a function or sub
routine, the user will enter something and then you can
use that value in your code.

Now I want to do the same thing except use my own
inputbox that I have designed. The problem I am facing is
how do I send this value back to the code that opened the
form in the first place.

Any Suggestions...
 
C

Chris Nebinger

Use a function to return the value:

strResponse = MyInputBox(Message,Title)

Now, suppose your form is named frmInputBox. Have a close
button, but on the OnClick event, dont' close the form,
just set the visible property to false. Also include a
label, named lblMessage, and a textbox named txtInput.


Function MyInputBox(strMessage as string, strTitle as
string)

dim f as Form
'Pass the Message and Title to the form via OpenArgs.
'Have the form change the caption and the label in the
OnOpen event
DoCmd.OpenForm "frmInput",,,,,acDialog ,strMessage & "-" &
strTitle
On Error Resume Next
set f = forms("frmInput")
'if an error occurred, user hit the X button
If Err.Number<> 0 then Exit Function
MyInputBox=f.Controls("txtInput")
End Function
 
D

Dan

Ok , I understand where your going with this code. But
the code doesn't stop to wait for an answer. It opens
the form but continues to process the code. So the end
result is always a null or empty string.

How do you stop the code to wait for an answer from the
user. If the user inputs something continue from that
point in the code.

Any suggestions..
 
R

Rick Brandt

Dan said:
Ok , I understand where your going with this code. But
the code doesn't stop to wait for an answer. It opens
the form but continues to process the code. So the end
result is always a null or empty string.

How do you stop the code to wait for an answer from the
user. If the user inputs something continue from that
point in the code.

Any suggestions..

Open the form using the acDialog argument and your calling code will be
paused until the form is either hidden or closed.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top