G
Guest
Okay, I'm about ready to loose my mind on this simple problem. I'm using
Access 2000 on Windows 2000. I'm creating a report/query form that is
completely unbound (it's getting data from an Oracle dbase). It's what they
want.
I would like to clear the form so if they make a mistake they can start over
without closing the form. I've spent lots of time searching here and the web
and found a simple solution. The code is below. I've got textboxes,
listboxes, combo boxes, and calendar for choosing dates. At one point I
thought about using Select Case for each type of control, but that seemed to
have its own set of problems. But I may go back to it.
The problem is once I run the ClearChoices sub my calendar doesn't work any
more. I've figured out that the problem is the value becomes "" and the
calendar code is looking for either a date or NULL. I didn't write the
calendar code and really don't want to rewrite it.
How do you really clear out the form controls and revert to an unaltered
state?? IE Unknown vs Empty?? Am I just dazed and confused? Is it really
this hard to clear a form?
Any help would be appreciated!
Karrie
Private Sub cmdClearChoices_Click()
On Error GoTo Err_cmdClearChoices_Click
Dim ctl As Control
Dim ctlType As String
For Each ctl In [Forms]![frmMTL]
If ctl.Tag = "CLEAR" Then
ctl = ctl.DefaultValue
End If
Next ctl
Exit_cmdClearChoices_Click:
Exit Sub
Err_cmdClearChoices_Click:
MsgBox Err.Description
Resume Exit_cmdClearChoices_Click
End Sub
Access 2000 on Windows 2000. I'm creating a report/query form that is
completely unbound (it's getting data from an Oracle dbase). It's what they
want.
I would like to clear the form so if they make a mistake they can start over
without closing the form. I've spent lots of time searching here and the web
and found a simple solution. The code is below. I've got textboxes,
listboxes, combo boxes, and calendar for choosing dates. At one point I
thought about using Select Case for each type of control, but that seemed to
have its own set of problems. But I may go back to it.
The problem is once I run the ClearChoices sub my calendar doesn't work any
more. I've figured out that the problem is the value becomes "" and the
calendar code is looking for either a date or NULL. I didn't write the
calendar code and really don't want to rewrite it.
How do you really clear out the form controls and revert to an unaltered
state?? IE Unknown vs Empty?? Am I just dazed and confused? Is it really
this hard to clear a form?
Any help would be appreciated!
Karrie
Private Sub cmdClearChoices_Click()
On Error GoTo Err_cmdClearChoices_Click
Dim ctl As Control
Dim ctlType As String
For Each ctl In [Forms]![frmMTL]
If ctl.Tag = "CLEAR" Then
ctl = ctl.DefaultValue
End If
Next ctl
Exit_cmdClearChoices_Click:
Exit Sub
Err_cmdClearChoices_Click:
MsgBox Err.Description
Resume Exit_cmdClearChoices_Click
End Sub