[AccessD] Need code help again Please x posted

Joe Hecht jmhla at earthlink.net
Mon Mar 21 23:56:06 CST 2005


I want to reset the values if the message box triggers.

If no message box then no reset.

Joe Hecht
jmhla at earthlink.net
28g
-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Darren DICK
Sent: Monday, March 21, 2005 9:42 PM
To: 'Access Developers discussion and problem solving'
Subject: RE: [AccessD] Need code help again Please x posted

Hi Joe 
At first glance...

You have 3 lines at the end of your code that goes like this...

Me.txtPieces.Value = 0
Me.ChkAllPieces.Value = 0
Me.chkNA.Value = False 

That is where ChkAllPieces is being 're-set'
To avoid this make sure there is an "exit sub" before this if certain
criteria are met
Otherwise the code is processed from top to bottom, without 'skipping', and
will 
eventually process the line Me.ChkAllPieces.Value = 0 if you haven't told it
to exit.

So make sure you exit the sub before that line if you don't want
Me.ChkAllPieces to = 0

IE After you make 'em click OK after warning them put in Exit Sub
Directly after Case vbOK
Eg

              Select Case lngRetval
                         Case vbOK
                         End sub
              End Select

Hope this helps

Darren



-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Joe Hecht
Sent: Tuesday, 22 March 2005 3:58 PM
To: 'Access Developers discussion and problem solving'; ACCESS-L
Subject: [AccessD] Need code help again Please x posted

I have a sub form where I need to do some logic checking. sfrmSampleSize
 
User either selects all pieces (ChkAllPieces), a yes no field , txtPieces, a
numeric txt box, (txtPieces) or N/A, (chkNA).
If more then one field is changed from 0 or not selected I run the following
code.
 
Private Sub ChkAllPieces_AfterUpdate()
DoCmd.SetWarnings False
    
    If Me.txtPieces.Value <> 0 Or Me.chkNA.Value = True Then
        
                Dim lngRetval As Long
 
               lngRetval = MsgBox( _
              "You have selected conflicting instructions." & vbCrLf & "" &
vbCrLf & "Please select one only:" & vbCrLf & "" &
vbCrLf & "All samples, A number of samples or N/A" & vbCrLf & "" & vbCrLf &
"", _
               vbOKOnly + vbExclamation + vbDefaultButton1, _
              "Conflicting Instructions")
 
              Select Case lngRetval
                         Case vbOK
              End Select
  
    End If
    
Me.txtPieces.Value = 0
Me.ChkAllPieces.Value = 0
Me.chkNA.Value = False
 
DoCmd.SetWarnings True
 
End Sub
 
Problem : I can no longer set value of chkAllPieces to true. It
automatically changes back to unchecked.
 
Can anyone tell me why?
 
Thanks
 
Joe 
 
 
--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com

-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com




More information about the AccessD mailing list