Reset Form (1 Viewer)

modest

Registered User.
Local time
Today, 05:15
Joined
Jan 4, 2005
Messages
1,220
Hey guys, take your time with this - i'm not in a hurry, it's just slipped my mind.

I'm reseting the form controls back to their default value. My code is as follows.

Code:
        For Each ctl In Me.Controls
            If ctl.Name Like "cbo*" Or ctl.Name Like "txt*" Then
                ctl.Value = ctl.DefaultValue
            End If
        Next ctl

The problem is the default value returns the literal string instead of the applied value. For instance if the default value was '=Null' then '=Null' is what you would actually see. I've tried ctl.requery but this does not work either.

Any suggestions?
 

elbweb

Self Taught Hero
Local time
Today, 05:15
Joined
Jul 28, 2006
Messages
126
my answer to that would be to just put some if statements in there...

like,
Code:
If InStr(ctl.DefaultValue, "Null") > 0 Then
    ctl.value = Null
ElseIf Right(ctl.DefaultValue,1) = "="  Then
    ctl.value = Right(ctl.DefaultValue, Len(ctl.DefaultValue) - 1)
End If
that code would say if the default value contains null, thenmake the value Null, else if the first character is "=" then the value is everything in the default value minus the first character.
 

Users who are viewing this thread

Top Bottom