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

change a field in a report from a form

Status
Not open for further replies.

WaltLukeIII

Programmer
Jun 28, 2000
199
0
0
US
I have a report that links to a report preview. I want to change one of the text labels in the report based upon a selected choice in the Form.

Walt III
SAElukewl@netscape.net
 
Try adding code to the Format Event Procedure of the Detail Section in the report. Something similar to the following
Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount as Integer)
If [Forms]![formname].[checkbox1]=True then
textbox.text="La De Da" else
If [Forms]![formname].[checkbox1]=False then
textbox.text="La La La" 
End if
End if
End Sub
 
I try the code that you gave with a few adjustments to fit my work. and I get the following error

"Object Required"

on this line

TextBox.Text1 = "La La La"



Walt III
SAElukewl@netscape.net
 
You can never change the text property in a report and can only do this in a form when the control has the focus.

You can change the label "Caption" property in the on format event of the section containing the label.

Duane
MS Access MVP
Find out how to get great answers faq219-2884.
 
So your saying that in order to make a variable "textarea" I would have to have it as a label. And that i have to do it from a form after I give the focus to the "textarea"/label in the report


Walt III
SAElukewl@netscape.net
 
You can place an unbound text box or a label on a report and then change its value (text box) or caption (label).

My response was due to three previous posts that incorrectly suggested you could change the "text" property of a text box on a report.

You can use code in the On Format event of the section containing the unbound text box like:

Code:
    If Forms!frmOpenForm!chkShow = True Then
        Me.txtMyTextBox = "Some Value"
      Else
        Me.txtMyTextBox = "Other Value"
    End If

Duane
MS Access MVP
Find out how to get great answers faq219-2884.
 
I think EliseFreedman code might work using the '.Value' property instead of the '.Text' property
 
I am not sure on the syntax of EliseFreedman's code and didn't know if it was a word wrap issue. I can't imagine ending a line with "Else".

Duane
MS Access MVP
Find out how to get great answers faq219-2884.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top