Run-time error (1 Viewer)

Danny

Registered User.
Local time
Today, 04:25
Joined
Jul 31, 2002
Messages
140
Greetings,

On my payment entry form, I've the following buttons: Add to input a new payment, and Edit, to make changes to existing payments. Lately, when users click Add, they receive run-time error '94' and clicking End will exit the database and create a _backup file, when they click Debug, the following is what they see
Private Sub txtCollectAMT_BeforeUpdate(Cancel As Integer)
'Add The Collected Payment
If IsNull(Me.txtCollectTot) = True Then
intCollectTot = Me.txtCollectAMT
End If

intSettleAmt = Forms!frmPICTSMain!frmFinancial!txtSettleAmt

If Forms!frmPICTSMain!frmFinancial!txtBalDue = 0 Then
MsgBox "Paid In Full " & intSettleame, vbInformation + vbOKOnly, "PAID IN FULL NOTICE"
Me.txtPaidInFull = "X"
Me.cmdCollectADD.Enabled = False
Me.cmdCollectEdit.Enabled = False
Me.cmdCollectSAV.Enabled = False
'Me.cmdCollectRpt.SetFocus
Cancel = True
Exit Sub
End If



intSettleAmt = Forms!frmPICTSMain!frmFinancial!txtSettleAmt above is higligted in yellow

TIA,

Regards,
 

June7

AWF VIP
Local time
Today, 00:25
Joined
Mar 9, 2014
Messages
5,472
frmFinancial is name of subform? Is it also name of container holding that form?
Is txtSettleAmt name of a field or a textbox or both?

Possibly should be using control's AfterUpdate event for this.

If you want to provide db for analysis, follow instructions at bottom of my post.
 
Last edited:

CJ_London

Super Moderator
Staff member
Local time
Today, 09:25
Joined
Feb 19, 2013
Messages
16,612
perhaps you need

intSettleAmt = Forms!frmPICTSMain!frmFinancial.form.txtSettleAmt
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 03:25
Joined
Feb 28, 2001
Messages
27,186
Error 94 is "Invalid use of Null" which is not surprising. CJ suggested a valid possibility - that you have a syntax error due to the reference you used leading to an impossible condition. (Though I'm perhaps SLIGHTLY surprised you got that error vs. some other error. But only slightly.)

Code:
intSettleAmt = Forms!frmPICTSMain!frmFinancial!txtSettleAmt

The syntax of that statement is (stepwise)
1. Find the Forms collection.
2. Within the Forms collection, find object frmPICTSMain
3. Within the elements of frmPICTSMain, find frmFinancial
4. Within the elements of frmFinancial find txtSettleAmt

You used the "bang" syntax which will do a name search of the object to the right of the exclamation point ("bang"). If it isn't there, you get a null reference, which propagates as a null when resolving the reference.

The error in part 3 is that a form contains sections and controls and event routines, but not forms. This is because Access has a "formality" that if you want a sub-form, you must put it in a special container called a sub-form control.

IF "frmFinancial" is the name of a sub-form control, then it can contain a form which in turn contains controls. So CJ's suggestion would work because that says "look in the form contained by sub-form control frmFinancial to find the desired field txtSettleAmt."

IF on the other hand, frmFinanicial is actually the name of the form being referenced as though it is a sub-form (and not the name of a control on frmPICTSMain), you might have another issue. You can only put one form inside another using the formality of a sub-form control - which usually should not have the same name as the form you intended to put inside the control.
 

Danny

Registered User.
Local time
Today, 04:25
Joined
Jul 31, 2002
Messages
140
Thank you everyone for your input. Yes, frmFinancial is the name of the subform. As per CJ_London’s suggestion, I made the necessary adjustment, and the error seems to go away.



Thank you!

Regards,
 

Users who are viewing this thread

Top Bottom