472,985 Members | 2,751 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Access: when subform's query has no data. Creates an error message in main form

Hi, Im using Access 97, and I have two subforms which have a total for
the query'd data. I then go and total the two together on the main
form. But, when one has no data it brings up an error. I have searched
for the answer and tryed both these approachs...but dont work for me.
I am working in the control source of a text box.

=IIf(IsNull([sqry1].[Form]![txtSumUnit1]),IIf(IsNull([sqry2].[Form]![txtSumUnit2]),[sqry1].[Form]![txtSumUnit1],[sqry2].[Form]![txtSumUnit2])+[sqry1].[Form]![txtSumUnit1]),[sqry2].[Form]![txtSumUnit2])

or

=nz([sqry1].[Form]![txtSumUnit1],0)+ nz(sqry2].[Form]![txtSumUnit2],0)

Aparently these should work, but dont. Whatever Im doing wrong can
someone help?

thanks a million

Gran
Nov 13 '05 #1
2 2901
The expressions you have will not work if the subform has no records. In
that case, the subform displays completely blank, and any attempt to refer
to the non-existent text box in the subform naturally produces an error.

To fix that, you could make the subform's Recordset updatable or change its
AllowAdditions property to Yes. Alternatively you could examine the
RecordCount of its RecordsetClone, or test for IsError().

This kind of thing:

=IIf([sqry1].[Form].[RecordsetClone].[RecordCount] > 0, Nz([sqry1].[Form],
0), 0)

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Gran" <gr***********@bbc.co.uk> wrote in message
news:8b*************************@posting.google.co m...
Hi, Im using Access 97, and I have two subforms which have a total for
the query'd data. I then go and total the two together on the main
form. But, when one has no data it brings up an error. I have searched
for the answer and tryed both these approachs...but dont work for me.
I am working in the control source of a text box.

=IIf(IsNull([sqry1].[Form]![txtSumUnit1]),IIf(IsNull([sqry2].[Form]![txtSumU
nit2]),[sqry1].[Form]![txtSumUnit1],[sqry2].[Form]![txtSumUnit2])+[sqry1].[F
orm]![txtSumUnit1]),[sqry2].[Form]![txtSumUnit2])
or

=nz([sqry1].[Form]![txtSumUnit1],0)+ nz(sqry2].[Form]![txtSumUnit2],0)

Aparently these should work, but dont. Whatever Im doing wrong can
someone help?

thanks a million

Gran

Nov 13 '05 #2

Thanks, fixed it through creating two text boxes and sperating the parts
of the expression that may cause an #error. Then, used
Iif(iserror([txt1]),0,[txt1])+Iif(iserror([txt2]),0,[txt2])... then made
txt1 and txt2 not visible.

and it worked. Just needed a fresh approach!
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Julia Baresch | last post by:
Hi everyone, My company recently upgraded from Office 97 to Office XP. As those who've read my other posts know I have a database with 3 nested subforms Main form-->First Subform-->Second...
5
by: will eichert | last post by:
Greetings. I have a problem with a combo box incorrectly displaying blank items when returning to a form from a modal form. It's fine when the main form first comes up, but gets messed up when the...
49
by: Yannick Turgeon | last post by:
Hello, We are in the process of examining our current main application. We have to do some major changes and, in the process, are questionning/validating the use of MS Access as front-end. The...
12
by: Wadim Grasza | last post by:
I want to store and display (on a form or a report) multiple pictures per record in an access database. The pictures are not stored within the database. They are stored as files and the database...
20
by: Deano | last post by:
Just looking at C Sharp to see if it might be worth my while learning something new. Has anyone here tried a .NET language and tried to replicate a existing Access app? I would be interested to...
2
by: Frav | last post by:
The Reps team have been experiencing that Access 2002 unexpectedly quits while working and also lots of Corruption Failures and "Record lock can not update" messages since the upgrade from...
1
by: Macbane | last post by:
Hi There, I have a main form that with a subform which is based on a parameter query. I have 2 controls on the main form & which are used as parameters in the query. It all works fine and...
4
by: etuncer | last post by:
Hello All, I have Access 2003, and am trying to build a database for my small company. I want to be able to create a word document based on the data entered through a form. the real question is...
2
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

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.