date range

G

Gerald

Dears,

I have a report which pulls info. on date range, but if no data processed
within these dates, it gives me a error. I need the field that shows error
i.e. a total field with either zero or a text message

thanks , any help will be appreciated
 
A

Allen Browne

Test the HasData property of the report, e.g.:
=IIf([Report].[HasData], Sum([Amount]), Null)

Replace "Amount" with the name of your field.

Use 0 in place of Null if you wish, but it is better not to use Text here.
If you do, Access may think this value is text and not treat it correctly if
you do something else with it (such as comparing it to another number, or
adding it to another number.)
 
G

Gerald

put the code under
Private Sub ReportHeader_Format(Cancel As Integer, FormatCount As Integer)

End Sub

report gives me compile error, where should I put this code
Thanks

Allen Browne said:
Test the HasData property of the report, e.g.:
=IIf([Report].[HasData], Sum([Amount]), Null)

Replace "Amount" with the name of your field.

Use 0 in place of Null if you wish, but it is better not to use Text here.
If you do, Access may think this value is text and not treat it correctly if
you do something else with it (such as comparing it to another number, or
adding it to another number.)

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Gerald said:
Dears,

I have a report which pulls info. on date range, but if no data processed
within these dates, it gives me a error. I need the field that shows error
i.e. a total field with either zero or a text message

thanks , any help will be appreciated
 
A

Allen Browne

No code neeed.

I assumed you have a control with its Control Source set to:
=Sum([Amount])

The idea is to put this in the Control Source instead:
=IIf([Report].[HasData], Sum([Amount]), Null)

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Gerald said:
put the code under
Private Sub ReportHeader_Format(Cancel As Integer, FormatCount As Integer)

End Sub

report gives me compile error, where should I put this code
Thanks

Allen Browne said:
Test the HasData property of the report, e.g.:
=IIf([Report].[HasData], Sum([Amount]), Null)

Replace "Amount" with the name of your field.

Use 0 in place of Null if you wish, but it is better not to use Text
here.
If you do, Access may think this value is text and not treat it correctly
if
you do something else with it (such as comparing it to another number, or
adding it to another number.)

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Gerald said:
Dears,

I have a report which pulls info. on date range, but if no data
processed
within these dates, it gives me a error. I need the field that shows
error
i.e. a total field with either zero or a text message

thanks , any help will be appreciated
 
G

Gerald

yes, you are correct.

when I put under control source on print preview it gives me a error that
database can't find the macro

thanks

Allen Browne said:
No code neeed.

I assumed you have a control with its Control Source set to:
=Sum([Amount])

The idea is to put this in the Control Source instead:
=IIf([Report].[HasData], Sum([Amount]), Null)

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Gerald said:
put the code under
Private Sub ReportHeader_Format(Cancel As Integer, FormatCount As Integer)

End Sub

report gives me compile error, where should I put this code
Thanks

Allen Browne said:
Test the HasData property of the report, e.g.:
=IIf([Report].[HasData], Sum([Amount]), Null)

Replace "Amount" with the name of your field.

Use 0 in place of Null if you wish, but it is better not to use Text
here.
If you do, Access may think this value is text and not treat it correctly
if
you do something else with it (such as comparing it to another number, or
adding it to another number.)

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Dears,

I have a report which pulls info. on date range, but if no data
processed
within these dates, it gives me a error. I need the field that shows
error
i.e. a total field with either zero or a text message

thanks , any help will be appreciated
 
A

Allen Browne

What macro is it looking for?

Setting the Control Source of a text box does not refer to a macro.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Gerald said:
yes, you are correct.

when I put under control source on print preview it gives me a error that
database can't find the macro

thanks

Allen Browne said:
No code neeed.

I assumed you have a control with its Control Source set to:
=Sum([Amount])

The idea is to put this in the Control Source instead:
=IIf([Report].[HasData], Sum([Amount]), Null)

Gerald said:
put the code under
Private Sub ReportHeader_Format(Cancel As Integer, FormatCount As
Integer)

End Sub

report gives me compile error, where should I put this code
Thanks

:

Test the HasData property of the report, e.g.:
=IIf([Report].[HasData], Sum([Amount]), Null)

Replace "Amount" with the name of your field.

Use 0 in place of Null if you wish, but it is better not to use Text
here.
If you do, Access may think this value is text and not treat it
correctly
if
you do something else with it (such as comparing it to another number,
or
adding it to another number.)

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Dears,

I have a report which pulls info. on date range, but if no data
processed
within these dates, it gives me a error. I need the field that shows
error
i.e. a total field with either zero or a text message
 
G

Gerald

I will check again in another of my database and reply if any issues

thanks for your help, Allen

Allen Browne said:
What macro is it looking for?

Setting the Control Source of a text box does not refer to a macro.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Gerald said:
yes, you are correct.

when I put under control source on print preview it gives me a error that
database can't find the macro

thanks

Allen Browne said:
No code neeed.

I assumed you have a control with its Control Source set to:
=Sum([Amount])

The idea is to put this in the Control Source instead:
=IIf([Report].[HasData], Sum([Amount]), Null)

put the code under
Private Sub ReportHeader_Format(Cancel As Integer, FormatCount As
Integer)

End Sub

report gives me compile error, where should I put this code
Thanks

:

Test the HasData property of the report, e.g.:
=IIf([Report].[HasData], Sum([Amount]), Null)

Replace "Amount" with the name of your field.

Use 0 in place of Null if you wish, but it is better not to use Text
here.
If you do, Access may think this value is text and not treat it
correctly
if
you do something else with it (such as comparing it to another number,
or
adding it to another number.)

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Dears,

I have a report which pulls info. on date range, but if no data
processed
within these dates, it gives me a error. I need the field that shows
error
i.e. a total field with either zero or a text message
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top