Hide/unhide subform

Groundrush

Registered User.
Local time
Today, 02:18
Joined
Apr 14, 2002
Messages
1,376
I have looked at a couple of posts regarding Hiding a subform
but I am having a couple of problems with mine

I have a subform that I only want to be visible when a toggle box has been checked, and invisible again when unchecked.

To hide the subform when opening the main form

I am using:

Private Sub Form_Load()
Forms!frmAlarms!frmPropertyAddressInput.Visible = False
End Sub

which seems to works ok

Then when I check the toggle box on one of the records

I am using:

Private Sub FirstLetterSent_Click()
Forms!frmAlarms!frmPropertyAddressInput.Visible = True
End Sub

the problem is that when I click on the toggle box it opens the subform for all the other records aswell and I cant turn it off untill I close the database down and re open.

how do I make it visible/invisible when a toggle box has been checked/unchecked, and keep it that way when scrolling through all the records and also when the the database has been closed and re opened

Thanks
 
Something like...
Code:
If Me.FirstLetterSent = true then
Forms!frmAlarms!frmPropertyAddressInput.Visible = True 
else
Forms!frmAlarms!frmPropertyAddressInput.Visible = False 
End if
in the forms OnCurrent event

IMO
 
I think you're saying that as you go from record to record on the form, the subform stays visible if you just click the toggle button once. You'd like the state of the toggle button (and therefore the invisibility of the subform) to be restored to unchecked (and invisible) as you move to another record.

You need to put some code into the On Current event of the form. Code in that event will run as the form moves to a different record.

You can just put this code there:

Me.togglebuttonname = False
Forms!frmAlarms!frmPropertyAddressInput.Visible = False
 
IMO, if I was reading the poster's intent correctly, your code might have an issue. I am assuming the toggle button isn't a bound control. Thus, it will remain "clicked" as the user moves from record to record.
 
No, It's bound, I took a look at Groundrush's DB the other day, Unless it's changed

IMO
 
Different records may not have the toggle boxes ticked, I only want the subform visible if the toggle has been ticked for the current record
 
Hi Imo

I have added to the database since you last saw it.

this post is regarding a new subform that I have created

it's just an address subform for the user to type in an address for the warning letters to be sent to

I only want it visible when the action 1 or action 2 toggle buttons have been checked.

:)
 
If you have left the toggle buttons the same as they were use my code but if you have changed them to unbound toggle buttons (not connected to your table) then go with dcx693's solution

IMO
 
Last edited:
Thanks for all the quick replies and advice

IMO thanks again you have done it again
the toggle buttons were the same and I have just tried your code and it worked first time,


I am envious on how you can do that so quickly.:p
 
Groundrush said:

I am envious on how you can do that so quickly.:p

It's more luck than judgement in my case!:)
 
Oh no it's Me Again

Hi IMO

I have been testing my database with every eventuality I can think of and I seem to have come up with another dilema that I can't sort out.


Do you know if it's possible to have all the toggle buttons related to same property checked at the same time as when the first one is?

if that makes any sense.

I found that If there are say 8 entries related to the same property ticked as "NO" false alarm, and 1 entry ticked as "YES"
leaving you 9 records stored

as soon as the count reaches =2 or >3 false alarms the user has to scroll through to all 10 records to check the action toggles, to prevent the warning messages from re activating.



Hope this catches you before you go to the pub.:)
 
The only thing I can think of at the moment is to create an update query which updates all related records to 'true' in the 'LetterSent' column of the main table, on the click of the toggle button. If I recall correctly, you could create this query to update by 'JobNumber'.
I hope I've explained that properly, it is nearly beer time so there's a pretty big blank space between the ears at the moment!! Let me know how you get on, if you get stuck post your DB again and I'll take a look.

IMO
 
Thanks IMO

interesting idea, I shall get my Access Books out over the weekend and have a look.

and Yep it's friday, and I think my weekly Entertainment budget alows me to go and get a few Bottles of Beer for the weekend

Have a good one yourself and thanks again for all your help

cheers:p
 
I think your Query should look like...

UPDATE Alarms SET Alarms.FirstLetterSent = True
WHERE (((Alarms.JobNo)=[forms]![frmAlarms]![JobNo]));

but thats only from memory. If you get stuck over the W/End post your DB here, I'll probably be online sometime tomorrow (depending on the hangover!)

Have a good W/End

IMO
 
Imo

your update qry is relying on the fact that the Job No's are not unique.

I need it to be updated by the Property Name

there may be hundreds of different Job No's for the same property and when the toggle boxes are used all the entries for that property needs to be updated.


It did work on the test database because I was using the same Job No to populate the Alarm Table

I then realised that it would not work if other No's are used

this attached database has unique No's to use

it isn't the latest one though, that's still at work, I forgot to save it on my memory stick to take home with me, I guess I was thinking about the beers I was about to get.

catch you later
 

Attachments

Hi Groundrush,
Try using this query in the OnClick event of the First Action toggle button...
Code:
    DoCmd.OpenQuery "qryUpdateFirstAction", acNormal, acEdit
IMO
 

Attachments

Show Off

IMO

You make it look so easy.

When you look at the solution it is obvious


WHERE ((([Concept Orders].BG_SITE)=[forms]![frmAlarms]![Property]));

I tried
WHERE((([Concept Orders].BG_SITE)=[forms]![frmAlarms]![JobNo].[Column](1).........something like that

and obviously it did not work.

Thanks again;)
 
IMO

HI

Remember when you helped me with, updating current records with the same propery?

Well I'm trying to automaticaly update new records that have the same property without having to use the toggle box again

I somehow thought you already did that, maybe I accidently changed something.

I have checked previous copies of the D.B but it seems that they are all the same.

you helped me to update current records with the same property, but I can't get it to update new records automaticaly


I tried to run the update qry on the form on current event procedure, but it did not like that


any Ideas?
 

Users who are viewing this thread

Back
Top Bottom