Avatar of linbayzak
linbayzakFlag for United States of America

asked on 

Make checkbox hold old value when form is opened to edit

Hi Experts,

This one is a little crazy.  I have a form that can be edited.  There are five checkboxes on the form and I put some code in the form load event to make the checkboxes false which is perfect unless the user is opening the form in edit mode.  I want the form to hold the value of the checkbox if the form is being edited but I don't want any checks in those boxes is the form is a new record.  Below is what I have, I included all the code for the form.  Thanks for your help.

Laura
Option Compare Database
 
Private Sub chkQuenchWaterOff_Click()
 
    If Me.chkQuenchWaterOff = True Then
       Me.chkQuenchWaterOn = False
    End If
    
End Sub
 
Private Sub chkQuenchWaterOn_Click()
 
    If Me.chkQuenchWaterOn = True Then
       Me.chkQuenchWaterOff = False
    End If
    
End Sub
 
Private Sub chkShoesEngagedStationFour_Click()
 
    If Me.chkShoesEngagedStationFour = True Then
       Me.chkShoesEngagedStationOne = False
       Me.chkShoesEngagedStationThree = False
       Me.chkShoesEngagedStationTwo = False
    End If
    
End Sub
 
Private Sub chkShoesEngagedStationOne_Click()
 
    If Me.chkShoesEngagedStationOne = True Then
       Me.chkShoesEngagedStationFour = False
       Me.chkShoesEngagedStationThree = False
       Me.chkShoesEngagedStationTwo = False
    End If
       
End Sub
 
Private Sub chkShoesEngagedStationThree_Click()
 
    If Me.chkShoesEngagedStationThree = True Then
       Me.chkShoesEngagedStationFour = False
       Me.chkShoesEngagedStationOne = False
       Me.chkShoesEngagedStationTwo = False
    End If
    
End Sub
 
Private Sub chkShoesEngagedStationTwo_Click()
 
    If Me.chkShoesEngagedStationTwo = True Then
       Me.chkShoesEngagedStationFour = False
       Me.chkShoesEngagedStationOne = False
       Me.chkShoesEngagedStationThree = False
    End If
    
End Sub
 
Private Sub cmbCancel_Click()
 
    Me.Undo
    DoCmd.Close acForm, "frmSetupLogsheetAnnealing"
    
End Sub
 
Private Sub cmbSubmitAnnealing_Click()
On Error GoTo Err_cmbSubmitAnnealing_Click
 
    DoCmd.Save
    DoCmd.Close acForm, "frmSetupLogsheetAnnealing"
 
Exit_cmbSubmitAnnealing_Click:
    Exit Sub
 
Err_cmbSubmitAnnealing_Click:
    MsgBox Err.Description
    Resume Exit_cmbSubmitAnnealing_Click
    
End Sub
 
Private Sub Form_Current()
    
    If AddNew = True Then
        DoCmd.GoToRecord , , acNewRec
    End If
    
    Me.cboToolingCart.Value = [Forms]![frmSetupHistory].[cboToolingCart].Value
    Me.txtHiddenDescription.Value = [Forms]![frmSetupHistory].[txtHiddenTCDesc].Value
 
    
End Sub
 
Private Sub Form_Load()
 
    If AddNew = False Then
        Me.cboToolingCart.Value = [Forms]![frmSetupHistory].[lstSetupHistory].Column(2)
    End If
    
    Me.chkShoesEngagedStationOne = False
    Me.chkShoesEngagedStationTwo = False
    Me.chkShoesEngagedStationThree = False
    Me.chkShoesEngagedStationFour = False
    
    Me.chkQuenchWaterOn = False
    Me.chkQuenchWaterOff = False
    
End Sub
 
Private Sub txtArgon_AfterUpdate()
 
     If Me.txtArgon.Value > 1 Then Me.txtArgon.Value = Me.txtArgon.Value / 100
     
End Sub
 
Private Sub txtArgon_LostFocus()
    
    'If Me.txtArgon.Value < 1 Or Me.txtArgon.Value > 100 Then
        'MsgBox "Please enter a value between 1 and 100 for the Argon data entry."
    'End If
 
    
End Sub
 
Private Sub txtFreq_AfterUpdate()
 
    If Me.txtFreq.Value > 1 Then Me.txtFreq.Value = Me.txtFreq.Value / 100
    
End Sub
 
Private Sub txtFreq_BeforeUpdate(Cancel As Integer)
 
End Sub
 
Private Sub txtGain_LostFocus()
 
    If Me.txtGain.Value < 1 Or Me.txtGain.Value > 100 Then
        MsgBox "Please enter a value between 1 and 100 for the Gain data entry."
    End If
 
End Sub
 
Private Sub txtHydrogen_AfterUpdate()
 
    If Me.txtHydrogen.Value > 1 Then Me.txtHydrogen.Value = Me.txtHydrogen.Value / 100
    
End Sub
 
Private Sub txtHydrogen_LostFocus()
 
    'If Me.txtHydrogen.Value < 1 Or Me.txtHydrogen.Value > 100 Then
        'MsgBox "Please enter a value between 1 and 100 for the Hydrogen data entry."
    'End If
    
End Sub
 
Private Sub txtIO_AfterUpdate()
 
    If Me.txtIO.Value > 1 Then Me.txtIO.Value = Me.txtIO.Value / 100
    
End Sub
 
Private Sub txtIO_BeforeUpdate(Cancel As Integer)
 
End Sub
 
Private Sub txtPO_AfterUpdate()
 
    If Me.txtPO.Value > 1 Then Me.txtPO.Value = Me.txtPO.Value / 100
    
End Sub
 
Private Sub txtPO_BeforeUpdate(Cancel As Integer)
 
End Sub
 
Private Sub txtVO_AfterUpdate()
 
    If Me.txtVO.Value > 1 Then Me.txtVO.Value = Me.txtVO.Value / 100
    
End Sub
 
Private Sub txtVO_BeforeUpdate(Cancel As Integer)
 
End Sub

Open in new window

Microsoft Access

Avatar of undefined
Last Comment
linbayzak
ASKER CERTIFIED SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of MikeToole
MikeToole
Flag of United Kingdom of Great Britain and Northern Ireland image

WHy not use Radio Buttons inside an Option Group for each of these?
Access will then enforce the rule that only one option in the group can be selected.
Avatar of linbayzak
linbayzak
Flag of United States of America image

ASKER

I wish I would have thought about radio buttons, that would have been better.  Unfortuanately it is too late to change this control.  I will try capricorn1's suggestion and get back to you soon.

Thanks :-)

Laura
Avatar of linbayzak
linbayzak
Flag of United States of America image

ASKER

Hi capricorn1, I tried to write a comment when I accepted your solution but I accidentally clicked submit too soon. Thanks for your help :-) And I will use radio buttons in the future, a much better method :-)

Laura
Microsoft Access
Microsoft Access

Microsoft Access is a rapid application development (RAD) relational database tool. Access can be used for both desktop and web-based applications, and uses VBA (Visual Basic for Applications) as its coding language.

226K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo