Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

URGENT - empty subforms

Status
Not open for further replies.

gwilym40

Programmer
May 2, 2002
31
GB
Hi

I have a unbound control on a form which is trying to reference a subform i.e. =[subform name].[Form]![ID field]
if there are no records it shows #error
I want it to show 0

any ideas please?
 
Hi, Something like this might help for your unbound control:

=IIf([frmSub1].[Form]![Description] Is Null,0,[frmSub1].[Form]![Description])

Hope that helps.
 
If the subform is bound to a table or query why not check the recordcount of the subform before assigning the variable. If it it 0 then set the variable to 0.

Paul
 
Assuming all code is correct ...

The reason you are getting the error is because your query behind your subform is not updatable. If it was and returned no records the field would be blank rather than #error. If you must use this non-updatable query checking for null will not work because the field in the query does not exist. An updatable query would at least show a new record row so the field exist It's just null)

You do indeed need to use dcount.

=IIf(DCount("*","subfrmquery")=0,0,=[subform name].[Form]![ID field]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top