Switchboard

wailingrecluse

Registered User.
Local time
Today, 23:22
Joined
Feb 10, 2009
Messages
50
Hi

Does anyone know how to hide a switchboard button so it's only displayed if the table has records?

I've hidden the ribbon etc from users but the issue is if they click on "browse records" and the table behind the form is empty, the only way back to switchboard is to close the db

Thanks in advance

WR
 
Don't open a table for your users. Create a form that is based on that table so you can include a close button.
 
Don't open a table for your users. Create a form that is based on that table so you can include a close button.

Hi

I'm not opening a table, the records are browsed in a form, but because i've locked down all the menu's, ribbon etc there is no option to close the form
 
Have you placed a button on your form to close? If using a datasheet format you can use a form/subform set up where your main form is unbound just so you can have the button on it and then you place the datasheet subform on it without Master/Child links.
 
Have you placed a button on your form to close? If using a datasheet format you can use a form/subform set up where your main form is unbound just so you can have the button on it and then you place the datasheet subform on it without Master/Child links.

Hi

Yes there is a button on the form to close, but if there are no records then the form is completely blank, i.e. no buttons or anything.

Is there not a way to check if the table is empty and if not display the button?
 
No, but if you do the main form/subform setup like I also gave that should work for you because the button can be on the main form and then won't be affected by the lack of records.
 
Hi again

Yes i'm sure your suggestion would work no problem, i'm not rubbishing it by any means - it's just not really a feasible option for me due to the cosmetics of the db.

I seem to remember using Access 2000 I could disable the menus et al and still have close buttons on the top right of the form - these seem to have disappeared in 2007 but perhaps I have disabled too many things so i'll try messing with that.

Thanks for your help
 
It's on my machine at work - let me have a go on Monday and if need be i'll attach a screen dump.

Have a good weekend and thanks again for the help!
 
in the forms open event test this

Code:
if dcount("*",me.recordsource) then
   msgbox("Nothing to display")  'if you like
   cancel = true
   exit sub
end if

then the form wont open.
you will NOW have to handle a 2501 error on the button trying to open the form.

Hope this helps


-------------
note - this is only a problem if the form doesnt let yuo add new records deliberately, or turns out to be non-updateable.

A normal form where you can add records will not exhibit the effect you describe
 
I often call a public function from the switchboard and check to see if the table has records in it using DCOUNT before opening the form or not.
 
in the forms open event test this

Code:
if dcount("*",me.recordsource) then
   msgbox("Nothing to display")  'if you like
   cancel = true
   exit sub
end if

then the form wont open.
you will NOW have to handle a 2501 error on the button trying to open the form.

Hope this helps


-------------
note - this is only a problem if the form doesnt let yuo add new records deliberately, or turns out to be non-updateable.

A normal form where you can add records will not exhibit the effect you describe
Hi there

Sorry, i've never messed with the switchboard in this way before - where does this code go?

I tried placing it here like this

Code:
 ' Open a form.
   if dcount("*",me.recordsource) then
   msgbox("Nothing to display")  'if you like
   cancel = true
 else
      Case conCmdOpenFormBrowse
            DoCmd.OpenForm rs![Argument]
endif

But it then tells me the case statement exists without select case.

Thanks

R
 
Hi

So i've discovered the problem with the above code in my setup - I have used the same form for viewing records and adding records and have only opened them in different ways, ie edit or read only, depending on which button is pressed.

This means if I add the above code then no-one will be able to add a new record - I will have to build a separate form for viewing records and this code will stop the browsing form from opening.

Thanks for your help guys.

WR
 

Users who are viewing this thread

Back
Top Bottom