I am totally confusing myself at this point. I have Access 2007 FE with SQL Server 2005 BE. I have linked the tables and using ODBC DSN connection.
I have a bound form with a PTQ as it's record source. This form contains a Save button, New Button and Close button. The detail of the form contains a two page tab control. This same form is used to edit existing records or add new records depending on how the form is called.
I have a "save" button as I want to validate that they have entered necessary data (I have my db set up with PK on each table and foreign key relationships to also insure data integrity). When the Form Dirty event is fired, I enable the "Save" button. On the click event of the Save button I have the following code:
Me.ChkOK2Save = True
If Me.Dirty Then
Me.Dirty = False
End If
This forces the Form_BeforeUpdate event with following code (code will be improved but this was written just as a quick check for flow thru and how it would work:
If IsNull(Me![Customer_Name]) Then
StrMsg = " Customer Name "
End If
If IsNull(Me![Customer_Status]) Then
StrMsg = StrMsg + " Status "
End If
If IsNull([Customer_StateCode]) Then
StrMsg = StrMsg + " State "
End If
If StrMsg > "" Then
MsgBox (" The following fields MUST be entered: " & StrMsg)
Cancel = True 'this will cancel update but leave info entered
Me.ChkOK2Save = False
End If
Seems to work fine but after BeforeUpdate code executes I receive "Error 2101 You entered an expression that has an invalid reference to the property" and highlights the "Me.Dirty = False" in the Click event of the save button.
I have tried different ways of handling with no luck.
Any help in what I am doing wrong would be greatly appreciated!
I have a bound form with a PTQ as it's record source. This form contains a Save button, New Button and Close button. The detail of the form contains a two page tab control. This same form is used to edit existing records or add new records depending on how the form is called.
I have a "save" button as I want to validate that they have entered necessary data (I have my db set up with PK on each table and foreign key relationships to also insure data integrity). When the Form Dirty event is fired, I enable the "Save" button. On the click event of the Save button I have the following code:
Me.ChkOK2Save = True
If Me.Dirty Then
Me.Dirty = False
End If
This forces the Form_BeforeUpdate event with following code (code will be improved but this was written just as a quick check for flow thru and how it would work:
If IsNull(Me![Customer_Name]) Then
StrMsg = " Customer Name "
End If
If IsNull(Me![Customer_Status]) Then
StrMsg = StrMsg + " Status "
End If
If IsNull([Customer_StateCode]) Then
StrMsg = StrMsg + " State "
End If
If StrMsg > "" Then
MsgBox (" The following fields MUST be entered: " & StrMsg)
Cancel = True 'this will cancel update but leave info entered
Me.ChkOK2Save = False
End If
Seems to work fine but after BeforeUpdate code executes I receive "Error 2101 You entered an expression that has an invalid reference to the property" and highlights the "Me.Dirty = False" in the Click event of the save button.
I have tried different ways of handling with no luck.
Any help in what I am doing wrong would be greatly appreciated!