Not detecting dirty form

bd528

Registered User.
Local time
Today, 03:39
Joined
May 7, 2012
Messages
111
Hi all,

I have a continuous form (no subforms) that is populated by a query.

On the form I have a checkbox that changes the forms recordsource via SQL ,via VBA.

Each record on the form has a textbox where the user can enter a value. I want a message to be displayed if the checkbox is clicked, only if a value has been entered in one of these textboxes.

I thought I could do this by using :-

Code:
Private Sub chkEAC_AfterUpdate()

If Me.Dirty = True Then
    MsgBox ("Changed")
End If

End Sub

But no message is displayed if I enter a number. Where am I going wrong?

Thanks in advance.
 
If the txtbox is unbound then I don't believe the record is marked as dirty, because no data has been change in the underlying record (Because the txtbox is unbound).

You would need to set a "changed" flag on the after update of the / any txtbox to check if things have changed on the form.
 
If the txtbox is unbound then I don't believe the record is marked as dirty, because no data has been change in the underlying record (Because the txtbox is unbound).

You would need to set a "changed" flag on the after update of the / any txtbox to check if things have changed on the form.

The textbox is bound. Does your second point still apply?
 
Nope. That doesn't make much sense.
How are you opening the forms recordset - can you post up the code?
 
I would add record selectors, to see if you have a pencil or an arrow

pencil indicates a dirty record. maybe your code is saving the record automatically in some way.

is the chkbox enabled? if not it won't update, and you won't get the after update message.


personally, I would use the forms after update event, I think - but it depends exactly what you are doing.
 
Nope. That doesn't make much sense.
How are you opening the forms recordset - can you post up the code?
Like this :-

Code:
Private Sub Form_Load()

Me!chkEAC.DefaultValue = True
Task = "SELECT t1.Sales_Ref, t1.Actual_SSD, t1.Customer_Name, t1.Tariff_Length, t1.Utility, t1.Supply_Num, t1.Region, t1.EAC, t1.D0019_EAC, Round([EAC]-[D0019_EAC],1) AS Difference, [EAC]/[D0019_EAC] AS [Difference %], t1.Agreed_EAC FROM qryCML as t1 WHERE (((t1.D0019_EAC) Is Not Null) AND ((t1.Agreed_EAC) Is Null) AND (([Actual_SSD]+15)<Date()));"
Me.RecordSource = Task

End Sub
 
I would add record selectors, to see if you have a pencil or an arrow

pencil indicates a dirty record. maybe your code is saving the record automatically in some way.

is the chkbox enabled? if not it won't update, and you won't get the after update message.


personally, I would use the forms after update event, I think - but it depends exactly what you are doing.

I enabled record selectors, and got a pencil when editing.

The check box is definitely enabled. I stepped through the code to check.
 
bd528 said:
On the form I have a checkbox that changes the forms recordsource via SQL ,via VBA.

Is this Checkbox in the Detail Section, i.e. is there a Checkbox for each Record? Or is it, perhaps, in the Form Header?

If it's in the Header, when you move off of the Record, to tick the Checkbox, the Record is automatically saved, and no longer Dirty.

Linq ;0)>
 

Is this Checkbox in the Detail Section...

Hmmm, the checkbox is in the form's header. I hadn't thought of that! I'll need to think of a different approach. Thanks for helping me realize my stupidity!
 

Users who are viewing this thread

Back
Top Bottom