How do i enable the user to hide/unhide controls upon using a toggle button?

  • Thread starter Cire via AccessMonster.com
  • Start date
C

Cire via AccessMonster.com

Hi all, i have several controls on my form so it looks quite cluttered. I
would want to use a toggle button to enable the user to hide/unhide controls.
I.e the form loads up with 4 controls, if the user wants more controls, he
clicks the toggle button which i've named "More Options" and 2 more controls
appears. When he clicks it again, these controls go back to hidden state, i.e.
controlname.visible = false

unfortunately i haven't dabbled with toggle buttons thus far in my previous
applications and searching across different forumns hasn't gave me any
information on it. So how do i do it?

my initial code:

Private Sub MoreOpt_Click()
With Me
.cbxRegion.Visible = True
.cbxCountry.Visible = True
End With
End Sub

both combo boxes have their visible set to no in the properties window. so
when i 1st click the toggle button, the controls show up but i don't know how
to hide it back when the user clicks the toggle button again.
hope someone can help me.

Thanks
Eric
 
C

Cire via AccessMonster.com

Cire said:
Hi all, i have several controls on my form so it looks quite cluttered. I
would want to use a toggle button to enable the user to hide/unhide controls.
I.e the form loads up with 4 controls, if the user wants more controls, he
clicks the toggle button which i've named "More Options" and 2 more controls
appears. When he clicks it again, these controls go back to hidden state, i.e.
controlname.visible = false

unfortunately i haven't dabbled with toggle buttons thus far in my previous
applications and searching across different forumns hasn't gave me any
information on it. So how do i do it?

my initial code:

Private Sub MoreOpt_Click()
With Me
.cbxRegion.Visible = True
.cbxCountry.Visible = True
End With
End Sub

both combo boxes have their visible set to no in the properties window. so
when i 1st click the toggle button, the controls show up but i don't know how
to hide it back when the user clicks the toggle button again.
hope someone can help me.

Thanks
Eric

another question: my form acts as a search filter, so all controls are
unbound. currently i'm using docmd.openquery to open the query generated on
the on_click event of the "search" command button. That query has its "WHERE"
clause determined by the criteria that the user selects from the form's
controls. I want to improve this by displaying the results in a sub-form, so
i can save the trouble of the user having to close the query window before
running another search.

in the sub-form i have put the source object as the query that i run but
whenever the user selects a different criteria and clicks search, the results
in the sub-form doesnt change. how do it i make the sub-form dynamically
change according to every click of the search button? i believe i have to put
a .requery somewhere? i've put it at the end of my Search on click event but
it doesnt work...and finally how do i export the results of the sub-form to
excel? cos previously if its in a query result page(docmd.openquery) i can
export without probs but now i can't. would appreciate if someone can answer
these.

thanks again
Eric
 
D

Duane Hookom

If this is truly a toggle button, it will have values of -1/true or 0/False.
Try something like:
Private Sub MoreOpt_Click()
With Me
.cbxRegion.Visible = .MoreOpt
.cbxCountry.Visible = .MoreOpt
End With
End Sub
 
C

Cire via AccessMonster.com

Duane said:
If this is truly a toggle button, it will have values of -1/true or 0/False.
Try something like:
Private Sub MoreOpt_Click()
With Me
.cbxRegion.Visible = .MoreOpt
.cbxCountry.Visible = .MoreOpt
End With
End Sub
Hi all, i have several controls on my form so it looks quite cluttered. I
would want to use a toggle button to enable the user to hide/unhide
[quoted text clipped - 28 lines]
Thanks
Eric

GREAT!! it worked!!! thanks!!!

btw a slight edit to the 2nd question. my user prefers the 1st approach i
took, i.e. the results appearing in a separate window which i used docmd.
openquery("queryname"), acviewnormal.acedit
but i've got a problem. my query is saved as a pass-through query so its
defaulted to read-only even though i've added adedit at the end. so when i
click export and select excel as file format, and don't check "save
formatted" i'll have an error "Operation is not supported for this type of
object". If i click save formatted, the export is successfull BUT there is
data loss in fields which has >255 characters.

in my previous application, i used a work-around by storing the result in a
table by executing a make table query. and then subsequently exporting that
table but "save formatted" musn't be checked if not data loss will still
occur. is there a way to still format the headers of the fields but still
retain the exact data, in this case description with >255 chars? example of
formatted headers:

i remember someone said u have to use recordset but i'm not familiar with the
code or are there other alternatives? and finally instead of saving the data
in a table, can i use another form to display the result?

thanks Eric
 
C

Cire via AccessMonster.com

Cire said:
If this is truly a toggle button, it will have values of -1/true or 0/False.
Try something like:
[quoted text clipped - 10 lines]
GREAT!! it worked!!! thanks!!!

btw a slight edit to the 2nd question. my user prefers the 1st approach i
took, i.e. the results appearing in a separate window which i used docmd.
openquery("queryname"), acviewnormal.acedit
but i've got a problem. my query is saved as a pass-through query so its
defaulted to read-only even though i've added adedit at the end. so when i
click export and select excel as file format, and don't check "save
formatted" i'll have an error "Operation is not supported for this type of
object". If i click save formatted, the export is successfull BUT there is
data loss in fields which has >255 characters.

in my previous application, i used a work-around by storing the result in a
table by executing a make table query. and then subsequently exporting that
table but "save formatted" musn't be checked if not data loss will still
occur. is there a way to still format the headers of the fields but still
retain the exact data, in this case description with >255 chars? example of
formatted headers:

i remember someone said u have to use recordset but i'm not familiar with the
code or are there other alternatives? and finally instead of saving the data
in a table, can i use another form to display the result?

thanks Eric

ohh i used the excel object method and the export is working :) but not the
colours lol..anyone knows where can i get a list of colours codes for " Cell.
Interior.Color = "
and can anyone point me to a quick code or guide to use the standard windows
save page instead of
strPath = "C:\Export.xls"
strPath = InputBox("Enter Excel Path " & _
"(e.g. " & strPath & ")", _
"Results", strPath)

thanks
 
D

Duane Hookom

You should be creating a new thread with a new question.
--
Duane Hookom
MS Access MVP

Cire via AccessMonster.com said:
Cire said:
If this is truly a toggle button, it will have values of -1/true or
0/False.
Try something like:
[quoted text clipped - 10 lines]
Thanks
Eric

GREAT!! it worked!!! thanks!!!

btw a slight edit to the 2nd question. my user prefers the 1st approach i
took, i.e. the results appearing in a separate window which i used docmd.
openquery("queryname"), acviewnormal.acedit
but i've got a problem. my query is saved as a pass-through query so its
defaulted to read-only even though i've added adedit at the end. so when i
click export and select excel as file format, and don't check "save
formatted" i'll have an error "Operation is not supported for this type of
object". If i click save formatted, the export is successfull BUT there is
data loss in fields which has >255 characters.

in my previous application, i used a work-around by storing the result in
a
table by executing a make table query. and then subsequently exporting
that
table but "save formatted" musn't be checked if not data loss will still
occur. is there a way to still format the headers of the fields but still
retain the exact data, in this case description with >255 chars? example
of
formatted headers:

i remember someone said u have to use recordset but i'm not familiar with
the
code or are there other alternatives? and finally instead of saving the
data
in a table, can i use another form to display the result?

thanks Eric

ohh i used the excel object method and the export is working :) but not
the
colours lol..anyone knows where can i get a list of colours codes for "
Cell.
Interior.Color = "
and can anyone point me to a quick code or guide to use the standard
windows
save page instead of
strPath = "C:\Export.xls"
strPath = InputBox("Enter Excel Path " & _
"(e.g. " & strPath & ")", _
"Results", strPath)

thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top