mloucel
Member
- Local time
- Today, 11:51
- Joined
- Aug 5, 2020
- Messages
- 356
Hello Gurus:
I have the following form, that contains 2 sub forms [CONTINUOUS FORMS BOTH],
When MainForm is opened
SF1 is opened with AllowAdditions = False
and SF2 with AllowAdditions = True
when the user clicks the ADD button
I perform the following code:
stopping the user from entering any info on SF2 until a new record is created and saved.
So far so good and it works as it should.
MY PROBLEM
when the user clicks the SAVE button, I perform the opposite of the above code, because I need to re-enable SF2 so that the User can enter data.
I have an error routine that gives me the following error:
"Object doesn't support this property or method"
I have taken out the LINE:
acCmdSaveRecord
since the error started there.
then gave me the error again with the line:
"Forms("MainForm").SF2.enable = True"
and I am out of Ideas and I have NO IDEA how to solve it.
The COMPLETE code for BOTH buttons is at the end of the picture.
PLEASE kindly remember that I am asking for help because I am a beginner, I am trying my best not to ask many questions but from time to time I need help to get out of my own mess, do not feel offended by my stupid questions, I rather be a fool once and ask the question than forever and ignore my problem.
Thanks.
Maurice.
This is the ADD code:
=================================================================
This is the SAVE code:
I have the following form, that contains 2 sub forms [CONTINUOUS FORMS BOTH],
When MainForm is opened
SF1 is opened with AllowAdditions = False
and SF2 with AllowAdditions = True
when the user clicks the ADD button
I perform the following code:
Code:
Me.AllowAdditions = True
DoCmd.GoToRecord , "", acNewRec
Forms("MainForm").SF2.enable = False
stopping the user from entering any info on SF2 until a new record is created and saved.
So far so good and it works as it should.
MY PROBLEM
when the user clicks the SAVE button, I perform the opposite of the above code, because I need to re-enable SF2 so that the User can enter data.
Code:
DoCmd.RunCommand acCmdSaveRecord
Me.AllowAdditions = False
Forms("MainForm").SF2.enable = True
SaveButton.Enabled = False
I have an error routine that gives me the following error:
"Object doesn't support this property or method"
I have taken out the LINE:
acCmdSaveRecord
since the error started there.
then gave me the error again with the line:
"Forms("MainForm").SF2.enable = True"
and I am out of Ideas and I have NO IDEA how to solve it.
The COMPLETE code for BOTH buttons is at the end of the picture.
PLEASE kindly remember that I am asking for help because I am a beginner, I am trying my best not to ask many questions but from time to time I need help to get out of my own mess, do not feel offended by my stupid questions, I rather be a fool once and ask the question than forever and ignore my problem.
Thanks.
Maurice.
This is the ADD code:
Code:
Private Sub AddButton_Click()
On Error GoTo AddButton_Click_Err
On Error Resume Next
Me.AllowAdditions = True
' This is allowed in a continuous form
DoCmd.GoToRecord , "", acNewRec
Forms("MainForm").SF2.enable = False
SaveButton.Enabled = True
If (MacroError <> 0) Then
Beep
MsgBox MacroError.Description, vbOKOnly, ""
End If
AddButton_Click_Exit:
Exit Sub
AddButton_Click_Err:
MsgBox Error$
Resume AddButton_Click_Exit
End Sub
=================================================================
This is the SAVE code:
Code:
Private Sub SaveButton_Click()
On Error GoTo SaveButton_Click_Err
DoCmd.RunCommand acCmdSaveRecord
Me.AllowAdditions = False
Forms("MainForm").SF2.enable = True
SaveButton.Enabled = False
SaveButton_Click_Exit:
Exit Sub
SaveButton_Click_Err:
MsgBox Error$
Resume SaveButton_Click_Exit
End Sub