473,387 Members | 1,882 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

difficulty accessing computed text boxes on subform

1,271 Expert 1GB
I'm getting "Application-Defined or object-defined error in procedure ..." sometimes, and sometimes not. This happens whenever I try to get the value from one of more of these text boxes on frmOEOrder.

My main form is frmOEOrder and it has multiple tabs. The first tab, pgeGeneral, reveals one of two subpages, either subMisc or subDetail

O
Expand|Select|Wrap|Line Numbers
  1. n frmOEOrder
  2. !txtTotal is bound to
  3. =cswNullToZero([txtSubtotal])+cswRoundAmount2([txtTax])+cswNullToZero([txtFreight])+cswNullToZero([txtMHRLabor])
  4.  
  5. !txtTax is bound to
  6. =cswRoundAmount2(cswNullToZero([subDetail].[Form]![zstxtSalesTax])+cswNullToZero([subMisc].[Form]![zstxtSalesTax])+NZ([zstxtTaxFreight])+NZ([zstxtTaxMHR]))
  7.  
  8. !txtSubtotal is bound to
  9. =cswNullToZero([Forms]![frmOEOrder].[subDetail].[Form]![zstxtTotal])+cswNullToZero([Forms]![frmOEOrder].[subMisc].[Form]![zstxtTotal])
  10.  
  11. zstxtTaxFreight is bound to 
  12. =Nz([curFreight]*[dblExchangeRate])*NZ([dblTaxFreightPercent]/100)
  13.  
  14. zstxtTaxMHR is bound to
  15. =Sum(cswNullToOne([dblQtyOrdered])*[dblManHoursRequired])
  16.  
  17. txtMHRLabor is bound to
  18. =(cswRoundAmount2(cswNullToZero([subDetail].[Form]![zstxtMHRTotal])*cswNullToZero([Forms]![frmOEOrder]![txtHourly]))+cswRoundAmount2(cswNullToZero([subMisc].[Form]![zstxtMHRTotal])*cswNullToZero([Forms]![frmOEOrder]![txtHourly])))*[dblExchangeRate]
  19.  
  20. zstxtSalesTax is bound to
  21. =Sum([curSalesTax])
The bold data items are from the underlying dataset that the subform or form is bound to.

I notice when I am debugging, as I stop at various places, sometimes #Error# is displayed in these texboxes that are bound to a formula.

The specific thing that gives me a problem is when the user clicks on another tab, the pgeDetail tab. In the tab_Change event I want to get the value from frmOEOrder!txtTotal, but I cannot access the value at that time, I get the Application-Defined or object-defined error.

What is determining whether I can access these text boxes or not? Must the subform be in focus or something like that? Do I have to capture this txtTotal value before the tab Change event?

Thanks,
Jim
Sep 16 '10 #1
2 1312
Stewart Ross
2,545 Expert Mod 2GB
Hi Jim. This looks more like one of two problems to me: null values in computations, as null values stop computations in their tracks, and Nz (non-null) functions which are returning empty strings instead of 0's.

Nz(someval) will return an empty string, not a zero, leading to errors in any computation in which it is embedded. For example, if A, B and C are null then all the query engine will see as a result of Nz(A) + Nz (B) + Nz (C) is something like

computed value: ++

instead of

computed value: 0+0+0

If you are going to use Nz for numeric values you will have to qualify it appropriately:

Nz(someval, 0) for values not used as divisors, or
Nz(someval, 1) for values used as divisors (to avoid division by zero errors).

In addition, the emboldened expressions you post ALL have field values unprotected against nulls (even though there is an Nz in one of them!). These are modified to protect those fields (and to make Nz return 0) below.

Expand|Select|Wrap|Line Numbers
  1. zstxtTaxFreight is bound to 
  2. =Nz([curFreight], 0)*Nz([dblExchangeRate], 0)*NZ([dblTaxFreightPercent], 0)/100
  3.  
  4. zstxtTaxMHR is bound to
  5. =Sum(cswNullToOne([dblQtyOrdered])*Nz([dblManHoursRequired], 0))
  6.  
  7. txtMHRLabor is bound to
  8. =(cswRoundAmount2(cswNullToZero([subDetail].[Form]![zstxtMHRTotal])*cswNullToZero([Forms]![frmOEOrder]![txtHourly]))+cswRoundAmount2(cswNullToZero([subMisc].[Form]![zstxtMHRTotal])*cswNullToZero([Forms]![frmOEOrder]![txtHourly])))*Nz([dblExchangeRate],0)
  9.  
  10. zstxtSalesTax is bound to
  11. =Sum(Nz([curSalesTax], 0))
-Stewart
Sep 16 '10 #2
jimatqsi
1,271 Expert 1GB
Stewart,
The question is why are the values sometimes null and sometimes not. Or (I think) why is the recordset empty (giving nulls) sometimes and sometimes not.

If I click on one tab the values in these text boxes appear correctly and can be accessed without problem. When I click on a different tab that becomes momentarily not the case (I see "#ERROR#" in the text boxes) and code lines referencing the values in the text boxes fail. But alternate clicks can give varying results.

I solved the problem by changing my approach. Instead of trying to grab the values from the screen I read through the order detail lines and compute the total of the detail, which should already be available on the screen.

But I still wonder why this happens. Maybe it's a warning against binding text boxes to computations based on the underlying recordset.

Jim
Sep 21 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Gertjan van Heijst | last post by:
Hi, I really hope someone can help me because I've already spend 2 days on this problem and I'm not getting anywhere. I think the problem is that I don't really understand how text boxes store...
2
by: John Kreps | last post by:
(acc 2002) I've got six unbound text boxes on a subform that has a white background. Each of those six boxes has an expression that when true, will change its background from white to another...
7
by: Aravind | last post by:
Hi folks. I have 2 forms, frmBorrow and frmHistory frmBorrow has an unbound multi-column combo box (cboMember) and 7 unbound text boxes (MemNo, MemName, MemIC, MemType, CourseFaculty, Borrow,...
1
by: khan | last post by:
I have a form sale and 2 subform on it,saledetail and services. On my sale form I have two text boxes txtTotalSale and txtserviceTotal. One is showing total from saledetail subform and other is...
9
by: ielamrani | last post by:
Hi, I am trying to color a subform tab blue or red when 2 of its text boxes are not null. Here is my code that I tried but it's not working: If Forms!.First Is Not Null And Forms!.Last Is Not...
2
by: NCRStinks | last post by:
Hello Sorry everyone, I am back again - I have tried to find the answer and after 2 hours of not getting anywhere I have finally given in. I have a form with several text boxes which are...
1
by: kickergirl | last post by:
I'm not sure my title actually describes my problem, but here it goes. I am creating a form to track account information for participants. Basically, a single participant can be offered up to...
6
by: =?Utf-8?B?Sm9obiBBdXN0aW4=?= | last post by:
I have an app that displays about 20 items of data in text boxes. Very occasionally I need to allow these to be used for data entry, but the bulk of the time they are solely for information. They...
11
by: jwessner | last post by:
I have a form (Form1) which contains basic Project data and a subform listing the personnel assigned to the Project as a continuous form. Selecting a person on that project and clicking on a command...
2
topher23
by: topher23 | last post by:
Disclaimer: I've already come up with a solution for this issue, but I thought I'd post it in the hope that it could help someone else and on the off chance that someone has another solution. I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.