Default Value On Report

B

bdehning

I have a bound text field called "Comments" on a report. We use an input form to fill in this text field that is from the "Service Calls" Table.

What do I need to do to show the words "No Comments" for the "Comments field
when no text is entered on the form? When text is entered on the form is should show the words that have been entered.

Right now I see entries with blank fields on my report which I am trying to avoid by showing "No Comment"
 
D

Douglas J. Steele

Both text box form controls and table fields have a Default Property. Set it
to "No Comments". This, unfortunately, will prefill the field on new
records, so that your users will have to replace it if there is a comment.

Another, perhaps better, approach is to leave the field as is. As long as
it's got a Null, and not blanks, when there's no comment, you can create a
query that uses the Nz function to set it so that it doesn't look blank.
Your query would use Nz([Comments], "No Comments"). Use the query wherever
you would otherwise have used the table.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



bdehning said:
I have a bound text field called "Comments" on a report. We use an input
form to fill in this text field that is from the "Service Calls" Table.
What do I need to do to show the words "No Comments" for the "Comments field
when no text is entered on the form? When text is entered on the form is
should show the words that have been entered.
Right now I see entries with blank fields on my report which I am trying
to avoid by showing "No Comment"
 
V

Van T. Dinh

You can use a Calculated Field in the Query being used as the RecordSource
for the Report. Something like:

NonBlankComments: IIf(Len(Trim$([Comments] & "")) = 0,
"No Comments", [Comments])

--
HTH
Van T. Dinh
MVP (Access)


bdehning said:
I have a bound text field called "Comments" on a report. We use an input
form to fill in this text field that is from the "Service Calls" Table.
What do I need to do to show the words "No Comments" for the "Comments field
when no text is entered on the form? When text is entered on the form is
should show the words that have been entered.
Right now I see entries with blank fields on my report which I am trying
to avoid by showing "No Comment"
 
B

bdehning

Van T, Dinh

NonBlankComments: IIf(Len(Trim$([Comments] & "")) = 0,
"No Comments", [Comments])


DO I place in the query criteria field for "Comments" or control source for the report text box. I don't need Nonblankcomments: do I? I tried the IF statement in the report text box for comments and got extra ) in query expression. If placed in query criteria I get no records and I should get 6.

Help

--
Brian


Van T. Dinh said:
You can use a Calculated Field in the Query being used as the RecordSource
for the Report. Something like:

NonBlankComments: IIf(Len(Trim$([Comments] & "")) = 0,
"No Comments", [Comments])

--
HTH
Van T. Dinh
MVP (Access)


bdehning said:
I have a bound text field called "Comments" on a report. We use an input
form to fill in this text field that is from the "Service Calls" Table.
What do I need to do to show the words "No Comments" for the "Comments field
when no text is entered on the form? When text is entered on the form is
should show the words that have been entered.
Right now I see entries with blank fields on my report which I am trying
to avoid by showing "No Comment"
 
V

Van T. Dinh

It is not a criteria. It is called "Calculated Field", meaning a (query)
Field whose value is derived/calculated from the values of other Fields or a
set formula.

In your Query Grid, replace the Field name "Comments" in the Field name row
with the expression I posted. In the Report, change the ControlSource of
the relevant Control from "Comments" (which is no longer in the
RecordSource) to "NonBlankComments" (which is now a Field in the
RecordSource).

HTH
Van T. Dinh
MVP (Access)



bdehning said:
Van T, Dinh

NonBlankComments: IIf(Len(Trim$([Comments] & "")) = 0,
"No Comments", [Comments])


DO I place in the query criteria field for "Comments" or control source
for the report text box. I don't need Nonblankcomments: do I? I tried the
IF statement in the report text box for comments and got extra ) in query
expression. If placed in query criteria I get no records and I should get
6.
 
B

bdehning

Van Thank so much for the help. That worked at planned, but

Now is it possible to get greedy and have a way to keep the field blank on the report and query until the form it is on is completed and closed. If the person skips the"Comments" field it would say No Comments and otherwise would reflect what they type into the field.

I know I am getting greedy but is that possible or should I be happy with what I have learned from you already.

Thanks again.
--
Brian


Van T. Dinh said:
It is not a criteria. It is called "Calculated Field", meaning a (query)
Field whose value is derived/calculated from the values of other Fields or a
set formula.

In your Query Grid, replace the Field name "Comments" in the Field name row
with the expression I posted. In the Report, change the ControlSource of
the relevant Control from "Comments" (which is no longer in the
RecordSource) to "NonBlankComments" (which is now a Field in the
RecordSource).

HTH
Van T. Dinh
MVP (Access)



bdehning said:
Van T, Dinh

NonBlankComments: IIf(Len(Trim$([Comments] & "")) = 0,
"No Comments", [Comments])


DO I place in the query criteria field for "Comments" or control source
for the report text box. I don't need Nonblankcomments: do I? I tried the
IF statement in the report text box for comments and got extra ) in query
expression. If placed in query criteria I get no records and I should get
6.
 
V

Van T. Dinh

I am not sure of your set-up since the Report usually gets its data from the
Table, not Form so I am not sure the relationship between your Form & your
Report.

--
HTH
Van T. Dinh
MVP (Access)




bdehning said:
Van Thank so much for the help. That worked at planned, but

Now is it possible to get greedy and have a way to keep the field blank on
the report and query until the form it is on is completed and closed. If
the person skips the"Comments" field it would say No Comments and otherwise
would reflect what they type into the field.
I know I am getting greedy but is that possible or should I be happy with
what I have learned from you already.
 
B

bdehning

Van

The form used to enter comments is based on a Query that uses fields from 3 tables connected as follows. "Account Information" is 1 - Many to Location which is 1 - Many to "Service Calls". The comments field is located in the "Service Calls" Table which is fed from data completed on this form.

The info is then pulled by another query where you had me place the nonblankcomments to be used for a report to display.

Is this any help or too complicated.

--
Brian


Van T. Dinh said:
I am not sure of your set-up since the Report usually gets its data from the
Table, not Form so I am not sure the relationship between your Form & your
Report.

--
HTH
Van T. Dinh
MVP (Access)




bdehning said:
Van Thank so much for the help. That worked at planned, but

Now is it possible to get greedy and have a way to keep the field blank on
the report and query until the form it is on is completed and closed. If
the person skips the"Comments" field it would say No Comments and otherwise
would reflect what they type into the field.
I know I am getting greedy but is that possible or should I be happy with
what I have learned from you already.
 
V

Van T. Dinh

I wrote that the Report gets the data from Table(s), not Form. Therefore,
whatever you need has to be based on data in the Table(s), not what's on the
Form. Remember that Forms don't have data, Forms only display data from
Table(s).

--
HTH
Van T. Dinh
MVP (Access)



bdehning said:
Van

The form used to enter comments is based on a Query that uses fields from
3 tables connected as follows. "Account Information" is 1 - Many to
Location which is 1 - Many to "Service Calls". The comments field is
located in the "Service Calls" Table which is fed from data completed on
this form.
The info is then pulled by another query where you had me place the
nonblankcomments to be used for a report to display.
 
V

Van T. Dinh

Without looking at the database, I can't say. However, remember the Report
acts on / display all Records selected by the RecordSource while the status
of the Form affects only one Record, namely the Current Record on your Form.

Unless your Report RecordSource only contains one Record which is the
current Record on the Form, what you asked seem to be contradictory and I
don't think it is possible.

--
HTH
Van T. Dinh
MVP (Access)


bdehning said:
Van, fortunately one of the fews thiongs I am sure about is what you said about date from tables,etc.

So back to the question, is there any way to do what I asked in last post?
or do I have to structure differently based on what you said.
 
Top