From: Dennis on 22 May 2010 14:58 Hi, I'm trying to call a procedure that resideds in the main from teh sub-form. Here is the code in the main form: Public Sub Check_Batch_Balance() If IsNumeric(Me.txtDif) And Me.txtDif = 0 Then Me.txtOutOfBalance.Visible = False Else Me.txtOutOfBalance.Visible = True End If End Sub Here is the code in the sub-form: Private Sub txtAmt1_AfterUpdate() Call [frmContribute].Check_Batch_Balance ' Determine if batch is in balance End Sub When I run the code, I receive the following error message." Access can't find the field "[" referred to in your expression. I have the option to End, Debug, or Help. When I click on debug, it show the following line: Call [frmContribute].Check_Batch_Balance What am I doing wrong and how do I correct it? -- Dennis
From: Dirk Goldgar on 22 May 2010 16:58 "Dennis" <Dennis(a)discussions.microsoft.com> wrote in message news:8800D461-DAEE-4F5B-85F3-E586F25E2310(a)microsoft.com... > Hi, > > I'm trying to call a procedure that resideds in the main from teh > sub-form. > Here is the code in the main form: > > Public Sub Check_Batch_Balance() > > If IsNumeric(Me.txtDif) And Me.txtDif = 0 Then > Me.txtOutOfBalance.Visible = False > Else > Me.txtOutOfBalance.Visible = True > End If > End Sub > > > Here is the code in the sub-form: > > > Private Sub txtAmt1_AfterUpdate() > > Call [frmContribute].Check_Batch_Balance ' > Determine if batch is in balance > > End Sub > > > When I run the code, I receive the following error message." > > Access can't find the field "[" referred to in your expression. I have > the > option to End, Debug, or Help. When I click on debug, it show the > following > line: > > Call [frmContribute].Check_Batch_Balance > > > What am I doing wrong and how do I correct it? The easiest way is to access the Sub through the subform's Parent property, which returns a reference to the subform's parent form: Call Me.Parent.Check_Batch_Balance If you needed to call it from some other location where you didn't have a Parent reference, you could go through the Forms collection (so long as frmContribute is open): Call Forms!frmContribute.Check_Batch_Balance -- Dirk Goldgar, MS Access MVP Access tips: www.datagnostics.com/tips.html (please reply to the newsgroup)
From: Dennis on 22 May 2010 17:25 Dirk, That worked great! Thanks. Dennis
|
Pages: 1 Prev: Referring to text control in a form Next: Check for duplicates with multiple criteria |