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

change lable text on subform...

Status
Not open for further replies.

mjonson

Technical User
Joined
Mar 9, 2004
Messages
128
Location
GB
Hi,

on a subform open event the following code should change the labels of an option groups buttons ... but doesnt

ne ideas welcome

Private Sub Form_open(Cancel As Integer)
Select Case Me![vdcat]
Case "1"
Me!opt1.Caption = "1"
Me!opt2.Caption = "2"
Me!opt3.Caption = "3"
Me!opt4.Caption = "4"
Case Else
Me!opt1.Caption = "Yes"
Me!opt2.Caption = "No"
Me!opt3.Caption = "N/A"
[opt4].Visible = False
End Select
End Sub
 
It might also help us if you told us what it actually does, what errormsg...

That said, in the form open event, the form recordset might not be fully loaded, so referencing a controls value might not prove successful. You might try to put it in the forms on load event, or even the on current, if you want it to happen when you move to another record also.

If you're getting the 438 "Object doesn't support this property or method", you're probably trying to address the options, and not the labels, ensure you're working with the labels (label14...)

Roy-Vidar
 
Hi

changed to on load event..now get error

event procedure declaration does not match description of event having same name
 
Since you didn't provide any code, I'm just guessing. Have you created an on load event having a cancel parameter? If you have something like this:

[tt]Private Sub Form_Load(Cancel As Integer)[/tt]

then change to:

[tt]Private Sub Form_Load()[/tt]

The on load event doesn't take a parameter.

The following faq faq181-2886 addresse amongst other some of the issues making it easier to assist and how to get the most out of the membership;-)

Roy-Vidar
 
youre right - was the parameter

form loads fine just doesnt change label captions
code now looks like

Private Sub Form_Load()
Select Case Me![vdcat]
Case "1"
Me!opt1.Caption = "1"
Me!opt2.Caption = "2"
Me!opt3.Caption = "3"
Me!opt4.Caption = "4"
Case Else
'[opt1].Visible = False
Me!opt2.Caption = "Yes"
Me!opt3.Caption = "No"
Me!opt4.Caption = "N/A"

End Select
End Sub
 
What is the value of Me![vdcat] when executing (does it have a value), and what datatype is the field it's bound too, according to the routine, it should be text?

Try setting a breakpoint on the first executable line (hit F9 when the cursor is within it), then open the form, and you should be thrown to the VBE with that line highlighted. Then step thru the code (F8), check the values of the controls and variables by hovering the mouse over them (or select them and hit SHIFT+F9).

Else usage of Debug.Print <variable of control> in the code is encouraged. The results can be viewed in the immidiate pane (CTRL+G)

Roy-Vidar
 
the datatype is autonumber (integer?)
 
Hi,
this still wont work this is a continuous form
I now have two option groups both are hidden and am trying to use visible control to show when on form load.

If vdeqcatid = 1 Then
Me!vdea1.Visible = True
Me!vdea2.Visible = False
Else
Me!vdea1.Visible = False
Me!vdea2.Visible = True
End If

all i get is 1 group[vdea1] visible all the time
 
Again very little information to work on.

If it is one set of controls for the subform:
If the sort order of the subform recordsource gives you the record containing "vdeqcatid = 1" as the first record of the form, then that's expected.

If you want the option group visible properties to change by which record is the current, try placing the code also in the on current event of the form (or perhaps just the on current).

And - please - for more errorchecking - try what I stated above, and do tell what errormessage if any, what value does the control have when executing the code.

If it's one set of controls per each record, I don't know if that's possible.

Roy-Vidar
 
Roy,
sorry for the vagueness

"If it is one set of controls for the subform:
If the sort order of the subform recordsource gives you the record containing "vdeqcatid = 1" as the first record of the form, then that's expected."

the subforms controls for each record should change depending on value of vdeqcatid

"try placing the code also in the on current event of the form (or perhaps just the on current)"

the on current does change the control depending on value but does so for all records

"If it's one set of controls per each record, I don't know if that's possible"

the result i need is the same as a report detail print for each record
so the answer is that it cant be done

thanks for your advice
 
I try to be carefull with stating something is not possible, I believe I was a little more "vague" than that in my reply;-)

But - programmatic attempts on conditional formatting on continuous forms would need somewhat more tweaking than the usual toggling of properties. No matter how many times a control is displayed (how many rows in a continuous form) it's one and the same control. And toggling the properties of it, is shown on all rows...

Best way of doing conditional formatting on continuous forms, is with conditional formatting - but I don't think they work for check boxes, option groups...

There might off course be ways, but just I haven't seen them. You might try some other sites, for instance Stephen Lebans site Contents, The Access Web or try a google...

Roy-Vidar
 
also am using 97 - no cond formatting
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top