setting an unbound textbox in a report

C

Carole

Ok, this should be simple but i seem to be hitting a brick wall.

I have one field that is unbound that i would like to set depending on what
another bound field is equal to. So in this case if the textbox named "UN#"
equals "N/A" my textbox named "Dow" should be "Non Dow"....

The code i have so far in the detail_format of the report is this.

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dow = If (UN# = "N/A") Then
Dow.Value = "Non Dow"
Else
Dow.Value = "Dow"
End If
End Sub

This is obviously not working. Both fields/textboxes are in the same detail
footer not sure if that makes a difference. Could someone point me in the
right direction here, is it possible to do this, this way?
 
A

Al Campagna

Carole,
Avoid using "#" in your control names. It's used by access in Date
handling. While this may not cause a problem, it's best not to use it.
Try somthing like UNNo, or UNNum, etc..
That aside... I'll use UNNo.
This should work...

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If UN# = "N/A" Then
Dow = "Non Dow"
Else
Dow = "Dow"
End If
End Sub

OR....

Just make Dow an unbound calculated field... with a ControlSource of...
=IIF(UNNo = "N/A", "Non Dow", "Dow)
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."
 
M

MikeJohnB

Do not use reserved expressions in your field names (#)

=IIf([UNNo]="N/A","Non Dow","Dow")

Entered in the control source of the unbound text box should work
 
M

MikeJohnB

Sorry, Hadn't noticed Al's Response
--
Advice to Posters.
Check your post for replies or request for more information.
Consider providing some feed back to the response you have recieved.
Kindest Regards Mike B


MikeJohnB said:
Do not use reserved expressions in your field names (#)

=IIf([UNNo]="N/A","Non Dow","Dow")

Entered in the control source of the unbound text box should work
--
Advice to Posters.
Check your post for replies or request for more information.
Consider providing some feed back to the response you have recieved.
Kindest Regards Mike B


Al Campagna said:
Carole,
Avoid using "#" in your control names. It's used by access in Date
handling. While this may not cause a problem, it's best not to use it.
Try somthing like UNNo, or UNNum, etc..
That aside... I'll use UNNo.
This should work...

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If UN# = "N/A" Then
Dow = "Non Dow"
Else
Dow = "Dow"
End If
End Sub

OR....

Just make Dow an unbound calculated field... with a ControlSource of...
=IIF(UNNo = "N/A", "Non Dow", "Dow)
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."
 
M

Marshall Barton

Carole said:
Ok, this should be simple but i seem to be hitting a brick wall.

I have one field that is unbound that i would like to set depending on what
another bound field is equal to. So in this case if the textbox named "UN#"
equals "N/A" my textbox named "Dow" should be "Non Dow"....

The code i have so far in the detail_format of the report is this.

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dow = If (UN# = "N/A") Then
Dow.Value = "Non Dow"
Else
Dow.Value = "Dow"
End If
End Sub

This is obviously not working. Both fields/textboxes are in the same detail
footer not sure if that makes a difference. Could someone point me in the
right direction here, is it possible to do this, this way?


That If is an invalid statement. You could use:

If (Me.[UN#] = "N/A") Then
Me.Dow = "Non Dow"
Else
Me.Dow = "Dow"
End If
End Sub

But it is a poor practice to put data values (e.g. "N/A") in
your code. Better to have a little table that contains the
translations. Then the code could be:

Me.Dow = DLookup("Tranlation", "Translations" _
, "[UN#] = """ & Me.[UN#] & """"

Note that it also a poor praction to use names with anything
other than alphanumerix characters.
 

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