If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Hiding a subform
I have a subform on a main form which is shown/hidden by tab control,but
when it is hidden all I see/get is a blank tab control. I have tried various macros to close it or minimise it, but they don't work. So is there a way to hide a subform when not needed and then show it when it is. Thanks |
#2
|
|||
|
|||
Hiding a subform
Use the Change event for the tab control.
The way I do it is like this-- Private Sub ClientTab_Change Select Case Me.ClientTab Case 0 Me.[NameOfSubformControlA].SourceObject = "[FormA]" Me.[NameOfSubformControlB].SourceObject = "" Case 1 Me.[NameOfSubformControlA].SourceObject = "" Me.[NameOfSubformControlB].SourceObject = "[FormB]" End Select End Sub The tab control has a value of 0 when on the first page, 1 when on the second page and so on. With the above code, every time the user clicks on a tab, the sub for change event of the tab control runs and chooses the correct form to display in the subform control. I also use code to set the master and child link fields every time I set the source object of a subform. Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia "Bob H" wrote in message ... I have a subform on a main form which is shown/hidden by tab control,but when it is hidden all I see/get is a blank tab control. I have tried various macros to close it or minimise it, but they don't work. So is there a way to hide a subform when not needed and then show it when it is. Thanks |
#3
|
|||
|
|||
Hiding a subform
Thanks, but what is SubformControlA and B. I take it Form A is the main
form??? Thanks Jeanette Cunningham wrote: Use the Change event for the tab control. The way I do it is like this-- Private Sub ClientTab_Change Select Case Me.ClientTab Case 0 Me.[NameOfSubformControlA].SourceObject = "[FormA]" Me.[NameOfSubformControlB].SourceObject = "" Case 1 Me.[NameOfSubformControlA].SourceObject = "" Me.[NameOfSubformControlB].SourceObject = "[FormB]" End Select End Sub The tab control has a value of 0 when on the first page, 1 when on the second page and so on. With the above code, every time the user clicks on a tab, the sub for change event of the tab control runs and chooses the correct form to display in the subform control. I also use code to set the master and child link fields every time I set the source object of a subform. Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia "Bob H" wrote in message ... I have a subform on a main form which is shown/hidden by tab control,but when it is hidden all I see/get is a blank tab control. I have tried various macros to close it or minimise it, but they don't work. So is there a way to hide a subform when not needed and then show it when it is. Thanks |
#4
|
|||
|
|||
Hiding a subform
A subform control is the "box" on the main form containing the subform. The
subform is a form in the listing of forms in the database window. Its name in the example is either FormA or FormB. The actual form is the Source Object for the subform control. Jeanette showed how to set the Source Object for two subform controls (NameOfSubformControlA and NameOfSubformControlB). I did not quite understand your question, but I have to say to the extent I understood it I read it differently than did Jeanette. I get the idea that you want either to hide the tab control or a tab page, but I am not clear what you mean when you say you are getting a blank tab control. To hide a subform you hide the subform control, but a tab control is not a subform control. You can hide a tab control, too, but as I said your meaning is not entirely clear. Bob H wrote: Thanks, but what is SubformControlA and B. I take it Form A is the main form??? Thanks Use the Change event for the tab control. The way I do it is like this-- [quoted text clipped - 29 lines] Thanks -- Message posted via http://www.accessmonster.com |
#5
|
|||
|
|||
Hiding a subform
What I would like to do if I can, is to hide the subform, whether it be
in or on a tab control or just by itself, when it is not required. This particualr subform is only required once a week at most, so I'd like to hide it, then bring it back into view when it is required. Thanks BruceM via AccessMonster.com wrote: A subform control is the "box" on the main form containing the subform. The subform is a form in the listing of forms in the database window. Its name in the example is either FormA or FormB. The actual form is the Source Object for the subform control. Jeanette showed how to set the Source Object for two subform controls (NameOfSubformControlA and NameOfSubformControlB). I did not quite understand your question, but I have to say to the extent I understood it I read it differently than did Jeanette. I get the idea that you want either to hide the tab control or a tab page, but I am not clear what you mean when you say you are getting a blank tab control. To hide a subform you hide the subform control, but a tab control is not a subform control. You can hide a tab control, too, but as I said your meaning is not entirely clear. Bob H wrote: Thanks, but what is SubformControlA and B. I take it Form A is the main form??? Thanks Use the Change event for the tab control. The way I do it is like this-- [quoted text clipped - 29 lines] Thanks |
#6
|
|||
|
|||
Hiding a subform
Assuming the subform control is named fsubMySub, you can toggle the Visible
property of the subform control, and change the caption of a label lblMyLabel. You could put the code in a command button Click event: Me.fsubMySub.Visible = Not Me.fsubMySub.Visible If Me.fsubMySub.Visible Then Me.lblMyLabel.Caption = "Hide Subform" Else Me.lblMyLabel.Caption = "Show Subform" End If Use your actual control names, of course. Bob H wrote: What I would like to do if I can, is to hide the subform, whether it be in or on a tab control or just by itself, when it is not required. This particualr subform is only required once a week at most, so I'd like to hide it, then bring it back into view when it is required. Thanks A subform control is the "box" on the main form containing the subform. The subform is a form in the listing of forms in the database window. Its name [quoted text clipped - 18 lines] [quoted text clipped - 29 lines] Thanks -- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/For...forms/200912/1 |
#7
|
|||
|
|||
Hiding a subform
I am getting an error message saying 'A problem occured while MS Access
was communicating withe OLE server or ActiveX control' when I insert the said code on the click even of a cmd button. I have changed the names accordinly so what am I missing. Thanks BruceM via AccessMonster.com wrote: Assuming the subform control is named fsubMySub, you can toggle the Visible property of the subform control, and change the caption of a label lblMyLabel. You could put the code in a command button Click event: Me.fsubMySub.Visible = Not Me.fsubMySub.Visible If Me.fsubMySub.Visible Then Me.lblMyLabel.Caption = "Hide Subform" Else Me.lblMyLabel.Caption = "Show Subform" End If Use your actual control names, of course. Bob H wrote: What I would like to do if I can, is to hide the subform, whether it be in or on a tab control or just by itself, when it is not required. This particualr subform is only required once a week at most, so I'd like to hide it, then bring it back into view when it is required. Thanks A subform control is the "box" on the main form containing the subform. The subform is a form in the listing of forms in the database window. Its name [quoted text clipped - 18 lines] [quoted text clipped - 29 lines] Thanks |
#8
|
|||
|
|||
Hiding a subform
That error message is about as useless as they get in terms of letting you
know what to do next. Thre are a few things you can try. Check your references. I don't think this is the problem, but it's worth a look. More information he http://allenbrowne.com/ser-38.html There could be some sort of corruption going on. More here (including the links in the article): http://allenbrowne.com/recover.html You could start with something like this: Create a new form. Copy a number of controls (maybe 20 or so) from the old form to the new one. Open the new form. If it works, add some more controls, and test again. I expect you get the idea. Likewise, add any code from the old form to the new one, testing as you go. A variation is to make a copy of the old form, then remove about half of the controls from the old form and try to open it. If it works, try again, but this time remove just half of the controls you removed the first time. By this process of elimination it may be possible to identify the offending control or code. If you can do so, replace it with a new one. It may be a control that seems to have nothing to do with the one giving you problems, but sometimes they fight with each other. Going a little farther, but short of the full recovery sequence, is to create a new blank database and import all of the objects from the old database into the new one. Read what Allen Browne has to say about preventing corruption (links above), including disabling Name AutoCorrect. It may be worthwhile going through the entire recovery sequence, which is likely to fix the problem. For decompiling I would move the database to the root of the C: drive, as it is much simpler to type the path. No matter what approach you take, start by making a copy of the database. Two would be better, or just make a number of copies so you can simply delete the copy you are working with if the repair doesn't work. In any case, work on a copy. Bob H wrote: I am getting an error message saying 'A problem occured while MS Access was communicating withe OLE server or ActiveX control' when I insert the said code on the click even of a cmd button. I have changed the names accordinly so what am I missing. Thanks Assuming the subform control is named fsubMySub, you can toggle the Visible property of the subform control, and change the caption of a label lblMyLabel. [quoted text clipped - 22 lines] [quoted text clipped - 29 lines] Thanks -- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/For...forms/200912/1 |
#9
|
|||
|
|||
Hiding a subform
What I did was start a fresh with a brand new form, then added the
subform, then the cmd button to show/hide the subform. I tried that and it worked great! So I then added controls one by one on to the new form, and kept trying the cmd button. Now I have a new form with all controls on as the old form, and a button that hides or shows the subform when required. Thanks for your help here. BruceM via AccessMonster.com wrote: That error message is about as useless as they get in terms of letting you know what to do next. Thre are a few things you can try. Check your references. I don't think this is the problem, but it's worth a look. More information he http://allenbrowne.com/ser-38.html There could be some sort of corruption going on. More here (including the links in the article): http://allenbrowne.com/recover.html You could start with something like this: Create a new form. Copy a number of controls (maybe 20 or so) from the old form to the new one. Open the new form. If it works, add some more controls, and test again. I expect you get the idea. Likewise, add any code from the old form to the new one, testing as you go. A variation is to make a copy of the old form, then remove about half of the controls from the old form and try to open it. If it works, try again, but this time remove just half of the controls you removed the first time. By this process of elimination it may be possible to identify the offending control or code. If you can do so, replace it with a new one. It may be a control that seems to have nothing to do with the one giving you problems, but sometimes they fight with each other. Going a little farther, but short of the full recovery sequence, is to create a new blank database and import all of the objects from the old database into the new one. Read what Allen Browne has to say about preventing corruption (links above), including disabling Name AutoCorrect. It may be worthwhile going through the entire recovery sequence, which is likely to fix the problem. For decompiling I would move the database to the root of the C: drive, as it is much simpler to type the path. No matter what approach you take, start by making a copy of the database. Two would be better, or just make a number of copies so you can simply delete the copy you are working with if the repair doesn't work. In any case, work on a copy. Bob H wrote: I am getting an error message saying 'A problem occured while MS Access was communicating withe OLE server or ActiveX control' when I insert the said code on the click even of a cmd button. I have changed the names accordinly so what am I missing. Thanks Assuming the subform control is named fsubMySub, you can toggle the Visible property of the subform control, and change the caption of a label lblMyLabel. [quoted text clipped - 22 lines] [quoted text clipped - 29 lines] Thanks |
Thread Tools | |
Display Modes | |
|
|