Inputbox Value Reference

  • Thread starter Thread starter DaveyC
  • Start date Start date
D

DaveyC

Hi

I have a form with a button on it that initiates a command that launches an
inputbox. The user then inputs the required value to the inputbox and
presses OK.

My question is this. How do I reference the user inputted value for use
within a query? I have looked through all the options in the expression
builder and I can not find reference to it. Do I need some form of code to
reference the entered value?

Any help much appreciated.
DaveyC
 
DaveyC -

If you have a value stored in a control on a form (and the form is open),
then you can refer to it from within the query. It will look like this:

=Forms![YourFormName]![YourControlName]

If you are using query design, you can use the Expression Builder to
navigate to the form control to help prevent typos.
 
One way is to assign the input value to a text box on your form (the text box
can be hidden) and the use the text box value as the critteria in your query.
The only problem with this is that as the input changes so does the criteria.
 
Daryl & Mike many thanks, I have used a combination of your ideas and some
code to solve the issue.

Private Sub Command118_Click()
Dim Message, Title, Default, NewAnalysisRef
Message = "Enter New Analysis Reference" ' Set prompt.
Title = "Copy Current Analysis" ' Set title.
Default = "COPY001" ' Set default.
' Display message, title, and default value.
NewAnalysisRef = InputBox(Message, Title, Default)
Forms![frm_Analysis]![Text119] = NewAnalysisRef
End Sub

where Text119 is hidden on the form, I always wondered why you would want to
hide something on a form... now I know!

DaveyC
 
Back
Top