What is wrong with referencing the SubForms directly? http://www.mvps.org/access/forms/frm0031.htm
You are sugesting a kluge that may not work all of the time. The busier the system the longer the delay.
What is wrong with referencing the SubForms directly? http://www.mvps.org/access/forms/frm0031.htm
You are sugesting a kluge that may not work all of the time. The busier the system the longer the delay.
Comic relief, as always.
Apparently Allan understands this, but I don't. I don't get this. what do you mean 'bound to a subform'?? Can't make sense out of that.
(not essential to answer, but I'd like to know)
Yes, it is definitely a timing issue!! I can even see how the msgbox pops up before the textboxes updates their values. Now, I'm trying to do it backwards, that is, including an event (say on lost focus) in the Subform, instead of the Form, but I can't make the subform to lose its focus!!!!! I thought it will lose its focus as soon as I click outside the "Subform"...but I guess I'm wrong.You are *definately* fighting a timing issue with the Tasker within Access. To make it work as you have it you either need to reference the SubForm directly instead of waiting for Access to resolve all of the indirections or place the values on the MainForm yourself in code.
What I mean is that the Textboxes get their values by adding records from the Subfom and not from the Form itself. I've tried to put the code inside the Subform and see if this is faster but with no luck!!
that's a complete re-iteration of what you said earlier.
but regardless, I can't understand this too well and I think Allan will be a better guy to talk to about it. good luck with it!
Thanks RuralGuy!!! Maybe I'll try to tackle the problem through another angle, how about using another event other than "Oncurrent"? Maybe if I explain what I want to accomplish it will be easier. I have a Form and a Subform were I insert accounting entries (you know debits and credits) and all I wanted to do is to warn the usser if their Debits and Credits are not the same (you know, their sum must always be equal), hence pop up a msgBox once the usser is done entering the amounts and gets out of the "Subform".What is wrong with referencing the SubForms directly? http://www.mvps.org/access/forms/frm0031.htm
You are sugesting a kluge that may not work all of the time. The busier the system the longer the delay.
When you leave the SubForm if the record is dirty then you will get a BeforeUpdate event from the SubForm as it will save the record. Use it to do the calculation and pop up your MsgBox. I assume it is just one SubForm in Continuous Form mode.
Thanks guys, I got away with your suggestion RuralGuy of calculating directly in the code so I change my code to the following:
Private Sub Form_Current()
Dim Debe, Haber As Single
Debe = DSum("Debe", "Comprobante Qry", "[IDDiario] = " & [Diario Nro])
Haber = DSum("Haber", "Comprobante Qry", "[IDDiario] = " & [Diario Nro])
If Debe = Haber Then
MsgBox "ok", vbOKOnly
Else
MsgBox "error", vbOKOnly
End If
End Sub
This instead of getting the values from a textbox which in turn calculates from a Subform. Bottom line, it gave me timing delay and a headache.
So thank you all in helping me out!!
Great! FYI in your "Dim Debe, Haber As Single" line, only Haber is dimentioned as a Single, Debe will be defined as a Variant. To have them both defined as Single you would need to use: Dim Debe As Single, Haber As Single
If your ready then go ahead and use the Thread tool and mark this thread as Solved.
Thanks for clarifying that for me!! that's new to me. I'll correct it in my code.Great! FYI in your "Dim Debe, Haber As Single" line, only Haber is dimentioned as a Single, Debe will be defined as a Variant. To have them both defined as Single you would need to use: Dim Debe As Single, Haber As Single
If your ready then go ahead and use the Thread tool and mark this thread as Solved.