Reset Combo Box

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

Guest

Hello,
I have an unbound cboRptLIN on frm_LINDialog, where the user chooses a system from the cbo, hits OK and a report is created with that system record. It works fine, but when I open the frm_LINDialog to preview a different system report, the cboRptLIN still has the previous system viewed in the cbo box. I would like it to be blank.

I tried a requery on the OnClose event of the frm_LINDialog, but it is not doing the trick:

Private Sub Form_Close()
Dim cboRptLIN As String
DoCmd.Requery "cboRptLIN"
End Sub

Does anyone have any suggestions on how I can get this to work? :0)
Thank you very much,
Mary
 
Hi Mary

An unbound control should revert to its default value (Null, unless you have
specified one) when a form is colsed and opened again. This suggests that
you are not really closing the form when you open the report, but only
hiding it by setting Me.Visible=False. A subsequent OpenForm will just make
it visible again, with the combo value unchanged.

Perhaps you could use the form's Activate event to set the combo value to
Null, or if this does not work (the activate event does not fire for modal
forms) you could add a hidden textbox to your form and when the OK button is
clicked, copy the combo value to the textbox and set the combo to Null.
Then use the textbox instead of the combo for your report selection
criteria.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand


MaryF said:
Hello,
I have an unbound cboRptLIN on frm_LINDialog, where the user chooses a
system from the cbo, hits OK and a report is created with that system
record. It works fine, but when I open the frm_LINDialog to preview a
different system report, the cboRptLIN still has the previous system viewed
in the cbo box. I would like it to be blank.
 
You might try placing this in the On Current event of frm_LINDialog:

Private Sub Form_Current()
Me.cboRptLIN = Null
End Sub

With this code, everytime the form is made current, the combo is cleared out.
 
Back
Top