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

Changing caption on command button

Status
Not open for further replies.

emtenzer

MIS
Nov 14, 2001
50
US
I have a subform with a command button. I want the caption on the command button to change depending on the value in a text box. I have tried on current, on load, on open, etc... i get the same message - Method or data member not found.

My code is simple:
If Me.Status = 1 Then
Me.btnNewCourtesyCall.Caption = "Click here to make a Courtesy Call"
Else
Me.btnNewCourtesyCall.Caption = "No calls to make"
End If

Thanks in advance for any insight.
 
Where is the code running, in the main form or subform? Where is the Status text box? Is the subform continuous or single view?

Do you understand if the subform is continuous, the caption will be the exact same for every record in the subform?

Duane
Hook'D on Access
MS Access MVP
 
I have tried to run the code from the subform.I have the status text box on another subform, however I put a txtStatus on this subform which references the other subform and the status comes through accurately. This subform is a single form, not continuous.
 
I tried it on Current and on Load and I get the same error message: the expression has an invalid reference to the property form/report and the debug goes to:

If Me.txtStatus = 1 Then
 
Yes, I compiled it with no errors until I place this code On Current. Thanks anyway.
 
I don't get any errors when I compile. When I open the main form, I get an error message and the debug goes to the line

If Me.txtStatus = 1 Then

The error message is "Object doesn't support this property or method
 
Hi!

Don't forget that a subform is not considered a loaded form in Access. Try getting to the controls through the main form:

If Forms("YourMainFormName").YourSubformControlName.Form.txtStatus = 1 then
Forms("YourMainFormName").YourSubformControlName.Form.btnNewCourtesyCall.Caption = "Click here to make a Courtesy Call"
Else
Forms("YourMainFormName").YourSubformControlName.Form.btnNewCourtesyCall.Caption = "No calls to make"
End If

hth


Jeff Bridgham
Purdue University
Graduate School
Data Analyst
 
Thanks, but same error message: "Object doesn't support this property or method" with debug going to

If Forms!frmClientInformation!frmCallAudit.txtStatus = 1 Then
 
emtenzer,
If you really still want help, you need to minimally respond to "Please provide your total code and which form it is running in".

Also, your syntax is not the same as Jeff's. You are missing
.Form.

Duane
Hook'D on Access
MS Access MVP
 
That is the total code on the OnCurrent of the subform frmCallAudit. I stated earlier that it was OnCurrent.
 
Adding the .Form. in gave me a new error:
"...expression that has an invalid reference to the property Form/Report.
 
That is the total code on the OnCurrent of the subform frmCallAudit.
Shouldn't it be in the OnCurrnt event of the [blue]Main Form[/blue]?

Randy
 
I am not getting any error messages when I put the code on the main form, but it also isn't accurate. It is only showing the "No calls to make" message whether the account has an appropriate status or not.
 
Hi!

One more thing to check:

Forms!frmClientInformation!frmCallAudit.txtStatus = 1

frmCallAudit looks like the name of the form. If so, this should be the name of the subform control on the main form, not the name of the form that you are using as a subform. So, the syntax is:

Forms!NameoftheMainForm!NameoftheSubformControl.Form.NameofControlonSubform

hth


Jeff Bridgham
Purdue University
Graduate School
Data Analyst
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top