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
|
|
0
|
|
|
|
Reply
|
Utf
|
5/22/2010 6:58:01 PM |
|
"Dennis" <Dennis@discussions.microsoft.com> wrote in message
news:8800D461-DAEE-4F5B-85F3-E586F25E2310@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)
|
|
0
|
|
|
|
Reply
|
Dirk
|
5/22/2010 8:58:16 PM
|
|
Dirk,
That worked great!
Thanks.
Dennis
|
|
0
|
|
|
|
Reply
|
Utf
|
5/22/2010 9:25:01 PM
|
|