Creating a pop-up text box

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

Guest

Is it possible to have a text box appear on screen (obviously in Access
2000/2003) depending on the result that the user chooses from a drop-down box?

In my table (and subsequent sub/form) I have a text field (list box) that
has Pass/Fail. If the user chooses 'Fail' then I want a text box to pop up
for them to enter the failure reasons. I have added a memo field to my table
called Failure Reason.

Thanks
 
Probably best to create a form that has a text box on it, and use
DoCmd.OpenForm to invoke it. Pass the Id of the current record as the Where
condition so that you link the comment to the correct record (read what's in
the Help file under OpenForm to see what I'm talking about)

Of course, this assumes that you're using a form to set the Pass/Fail. On
rereading your question, it sounds as though you might be updating the table
directly (and that you're using a lookup field for your Pass/Fail). Neither
of those are good options: you should never update tables directly, and
lookup fields in tables are generally considered to be a bad idea (see
http://www.mvps.org/access/lookupfields.htm at "The Access Web" for a
discussion of why)
 
Yes. A rough code example:

Private Sub cboMyCombo_AfterUpdate()
If Me.cboMyCombo = "Result1" Then
Me.txtMyText.Visible = True
Else
Me.txtMyText.Visible = False
End Sub

Put the same code in the form's Current event to show or hide the text box
as existing records are viewed.
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access
 
Doug

I do not update the table - the table gets updated via the subform 8-).
Therefore, would it be best to delete the look-up out from the table and just
have it as a normal field, and instead put the lookup into the form?
 
Therefore, would it be best to delete the look-up out from the table and just
have it as a normal field, and instead put the lookup into the form?

The answer to that is don't delete the field. Rather change the combo box
property back to a text box so that you can see the true value. Then in the
form you can bind the combobox's rowsource to the real lookup table (not
field) while maintaining the combo's controlsource to the field that you've
just altered.
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access Downloads
http://www.datastrat.com
http://www.mvps.org/access
 
Arvin

I have changed the field back to a text field, but now I'm slightly confused
as you still talk about the combo box as appearing on the row source on the
form?
 
Thanks Arvin

I think I was having a blonde moment earlier. was getting myself confused
between combos on table and forms, now sorted. All I need to do now is add
the code to make the text box appear.

Sometimes, we need to take an hour away from our database work.... ha ha
 
Arvin

I will be replying t this thread shortly as I'm having probs with the code
and errors being generated. I am busy taking screen shots that I will
hyperlink to my website through this newsgroup, so that it gives you a better
explanation. Unless of course this newsgroup is capable of include jpegs?
 
Back
Top