CALL UP CONTROL ON SUBFORM (1 Viewer)

FJM-P

New member
Local time
Today, 07:51
Joined
Aug 23, 2021
Messages
5
I have a main form called SALESORDERNUMBER which contains a subform called DETAILS.
On the mainform is a control named TESTNUMBER. This has 2 values to choose from. Either TP25A or TP68
On the subform is a control called STS1 which has a label called label22
I want to make the control and label on the subform visible when the value shown in TESTNUMBER is TP68 and not visible when the value shown is TP25A.
I have done similar before, but never with a subform.
Struggling with the code.....can anyone point me in a direction
 

FJM-P

New member
Local time
Today, 07:51
Joined
Aug 23, 2021
Messages
5
I found this earlier, but I still can't seem to work out the correct coding.....I tried quite a few combos but with no luck...
 

bob fitz

AWF VIP
Local time
Today, 07:51
Joined
May 23, 2011
Messages
4,726
I found this earlier, but I still can't seem to work out the correct coding.....I tried quite a few combos but with no luck...
Perhaps you can post a copy of the db
 

Mike Krailo

Well-known member
Local time
Today, 02:51
Joined
Mar 28, 2020
Messages
1,044
You haven't shown us what you have tried that doesn't work. All of the referencing techniques shown on the site moke123 linked to are how you can reference controls on a sub form and they do work. Show us your code and as Bob just mentioned, a database sample makes it much easier to see exactly what we're dealing with and make sure you use the code tags to display it.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 02:51
Joined
Feb 19, 2002
Messages
43,275
You can use conditional formatting for this. You could include a join to the mainform table in the RecordSource of the subform and select the TestNumber column.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 02:51
Joined
May 21, 2018
Messages
8,529
Probably something like this. Need to call this from the main forms current event and the TestNumber after update event.
Code:
Public Sub ShowHide()
   if TestNumber = "TP68" then
    me.SubformControlName.Form.STS1.visible = true
  else
    me.subformControlName.form.STS1.visible = false
  end if
end sub

This assumes the label is attached. Also if continous then all instances show or hide.
 

FJM-P

New member
Local time
Today, 07:51
Joined
Aug 23, 2021
Messages
5
.......Sorted now......thanks for the replies
 

Users who are viewing this thread

Top Bottom