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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Modifying a Control Source?

Status
Not open for further replies.

fiel

Programmer
Jun 3, 2007
96
US
Is there a way to put an 'if' statement in a control source similar to how I could use the Nz() or IsError() function in my control source?

What I'm trying to do is just have a textbox have a control source of '= 0' when there are no current records in the corresponding field in my query. I have tried using the Nz() function but continue getting errors.
 
The error I get is that the field is that the jet database engine does not recognize 'InfoRecords' as a valid field name or expression.

I'm not sure how, but I'm trying to set 'InfoRecords' to 0 when there are no current records in this field.
 
This statement doesn't make sense
when there are no current records in the corresponding field in my query
Fields don't have records, but records do have fields.

Are you wishing to display a 0 in a text box in a report header or footer when the report's record source doesn't return any records? If so, try:
=IIf([HasData],Count([InfoRecords]),0)

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Thanks, I have it working on certain parts. But is there a way to check if a certain field exists in a query?
 
You can loop through the Fields collection of a query to check for a particular field.

Maybe you should tell us what you are attempting to do...

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Well I'm trying to keep tack of hours for several tasks being done (for a total of 12). What I have is InfoRecords1, InfoRecords2... InfoRecords12. I'm making a report that summarizes all 12 tasks performed and I collect all my data from a query called qrRecordStack. The only thing is not all 12 tasks will have hours listed down. Some tasks will not really be needed and so I am going to try filling it in with a zero and continue with my tabulation; in the end I want to sum all these up which I just do by taking the sum of values from each textbox for each task.

I've attempted creating a dynamic crosstab report but came across too much confusion.
 
I guess I wouldn't continue with an un-normalized table structure. If you can't change the structure then consider using a union query to normalize.

I have a feeling I have suggested crosstab report solutions to you before. If not, let me know and I can point you in what I feel is a much more robust direction.

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top