Empty vs Null in Default Values

K

KJGinNC

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
 
P

PC Datasheet

From the Help file:
To undo changes in the current field or current record; if both have been
changed, press ESC twice to undo changes first in the current field and then
in the current record.

This will take you back to the original condition of the record when it
opened. Note that you can not undo after a record has been saved.
 
K

KJGinNC

Thanks but it's an unbound form with unbound controls. There is no record to
revert to. Hitting ESC clears the control that you are in but only if its a
text box. It does nothing for the listboxes or comboboxes.

I just found another post from yesterday regarding the same issue, but I'm
unable to get it to work in my code, but I'm still working on it.

Thanks for the suggestion

Karrie


PC Datasheet said:
From the Help file:
To undo changes in the current field or current record; if both have been
changed, press ESC twice to undo changes first in the current field and then
in the current record.

This will take you back to the original condition of the record when it
opened. Note that you can not undo after a record has been saved.

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
(e-mail address removed)
www.pcdatasheet.com


KJGinNC said:
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
 
K

KJGinNC

I've replaced my code with the code provided by Allen Browne in the 2/21/05
answer to "Reset the Form". This has fixed my problem with the calendar as
now the control value is NULL.

Thanks Allen!

Karrie
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top