Customized Inputbox

  • Thread starter Thread starter Dan
  • Start date Start date
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...
 
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
 
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..
 
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.
 
Back
Top