S
stoehrkr
Hello!
I'm fairly new to Access and VB and I've been getting along alright
but I've run into a problem with a message box I set up in my form.
Situation: the field FvsNF will always be filled out. Depending on
the answer (yes or no) certain fields become enabled or disabled. The
problem is if a user decides to change their answer for FvsNF after
filling out the wrong fields. The incorrect fields need to go back to
zero if they decide to proceed with that action. However if they
don't want to proceed I want to give them an out without losing their
entries. The code I have now is:
Private Sub FvsNF_BeforeUpdate(Cancel As Integer)
Result = MsgBox("Warning: All values in section will become zero.",
vbOKCancel)
If vbOK Then
TotalCC.Value = 0
OSCC.Value = 0
Clumpiness.Value = 0
ClumpDensity.Value = 0
ClumpSize.Value = 0
CrownDiff.Value = 0
CanopyLayers.Value = 0
Logging.Value = 0
pcc.Value = 0
DensOS.Value = -99
DensUS.Value = -99
sizeOS.Value = 0
sizeUS.Value = 0
sppOS.Value = 0
sppUS.Value = 0
Nonforesttype.Value = 0
ElevBelt.Value = 0
nonforestsppOS.Value = 0
nonforestOSCC.Value = 0
treecovergstype.Value = 0
Else
End If
End Sub
I've tried a lot of things under Else...and lots of different
combinations but I can't seem to get the cancel button to cancel! Any
help would be greatly appreciated!
Kali
I'm fairly new to Access and VB and I've been getting along alright
but I've run into a problem with a message box I set up in my form.
Situation: the field FvsNF will always be filled out. Depending on
the answer (yes or no) certain fields become enabled or disabled. The
problem is if a user decides to change their answer for FvsNF after
filling out the wrong fields. The incorrect fields need to go back to
zero if they decide to proceed with that action. However if they
don't want to proceed I want to give them an out without losing their
entries. The code I have now is:
Private Sub FvsNF_BeforeUpdate(Cancel As Integer)
Result = MsgBox("Warning: All values in section will become zero.",
vbOKCancel)
If vbOK Then
TotalCC.Value = 0
OSCC.Value = 0
Clumpiness.Value = 0
ClumpDensity.Value = 0
ClumpSize.Value = 0
CrownDiff.Value = 0
CanopyLayers.Value = 0
Logging.Value = 0
pcc.Value = 0
DensOS.Value = -99
DensUS.Value = -99
sizeOS.Value = 0
sizeUS.Value = 0
sppOS.Value = 0
sppUS.Value = 0
Nonforesttype.Value = 0
ElevBelt.Value = 0
nonforestsppOS.Value = 0
nonforestOSCC.Value = 0
treecovergstype.Value = 0
Else
End If
End Sub
I've tried a lot of things under Else...and lots of different
combinations but I can't seem to get the cancel button to cancel! Any
help would be greatly appreciated!
Kali