Enter value by clicking a record

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form with a blank "Question ID" field. I've coded it so that if the
user double clicks the field on the form, another form opens and displays a
list of question id's and the actual question text. Currently, the users are
only using the double click feature to pull up the form that lists the
options. After they find the question they want, they close the second form
and hand enter the ID into the "Question ID" field. Is there a way to code
the second form so that the user can simply click the question they want and
it will fill in the "Question ID" value on the first form automatically?
 
One way of doing that:
Few stages
********************************************
1. Create a Global variable under a module (not the form)
Global QuestionId as String
********************************************
2. When you open the second form, open it as dialog so the code will pause
until the second form is closed

docmd.OpenForm "FormName",,,,,acDialog
********************************************
3. When you close the second form apply the question Id to the variable you
declared in the first stage

QuestionId = Me.[QuestionIdFieldName]
********************************************
4. Now, to add to the OpenForm as specified in stage 2
QuestionId = ""
docmd.OpenForm "FormName",,,,,acDialog
If QuestionId <> "" Then
Me.[QuestionIdFieldName] = QuestionId
End If
********************************************
 
Back
Top