I have a form with various fields. When the form opens a majority of the fields are NOT enabled.
I then have a command button "Edit" that makes the fields editable with the Me.field.Enabled = True command.
When I try to mimic the save edit I get an error message stating you cannot disable a field that is in focus. My code is below:
I then have a command button "Edit" that makes the fields editable with the Me.field.Enabled = True command.
When I try to mimic the save edit I get an error message stating you cannot disable a field that is in focus. My code is below:
Code:
Private Sub btnEditRecord_Click()
Me!frmSitesAccount.Form!frmSiteUtility.Form!frmSitesUtilityMeterPoints.Form!ProfileClass.Enabled = True
Me!frmSitesAccount.Form!frmSiteUtility.Form!frmSitesUtilityMeterPoints.Form!MeterpointDetail.Enabled = True
Me!frmSitesAccount.Form!frmSiteUtility.Form!frmSitesUtilityMeterPoints.Form!dteEnergised.Enabled = True
Me!frmSitesAccount.Form!frmSiteUtility.Form!frmSitesUtilityMeterPoints.Form!dteDeEnergised.Enabled = True
Me!frmSitesAccount.Form!frmSiteUtility.Form!frmSitesUtilityMeterPoints.Form!cboActiveStatus.Enabled = True
Me!frmSitesAccount.Form!frmSiteUtility.Form!frmSitesUtilityMeterPoints.Form!cboCRCStatus.Enabled = True
End Sub
Private Sub btnSaveRecord_Click()
DoCmd.RunCommand acCmdRefresh
Me.btnSaveRecord.SetFocus
If MsgBox("Are you sure you want to save?", vbYesNo, "Save") = vbYes Then
Me!frmSitesAccount.Form!frmSiteUtility.Form!frmSitesUtilityMeterPoints.Form!ProfileClass.Enabled = False
Me!frmSitesAccount.Form!frmSiteUtility.Form!frmSitesUtilityMeterPoints.Form!MeterpointDetail.Enabled = False
Me!frmSitesAccount.Form!frmSiteUtility.Form!frmSitesUtilityMeterPoints.Form!dteEnergised.Enabled = False
Me!frmSitesAccount.Form!frmSiteUtility.Form!frmSitesUtilityMeterPoints.Form!dteDeEnergised.Enabled = False
Me!frmSitesAccount.Form!frmSiteUtility.Form!frmSitesUtilityMeterPoints.Form!cboActiveStatus.Enabled = False
Me!frmSitesAccount.Form!frmSiteUtility.Form!frmSitesUtilityMeterPoints.Form!cboCRCStatus.Enabled = False
End If