Show/Hide Combo box

S

SimonT

Hi Guys,

Does anyone know the syntax to hide a combo box on a form if it is opened in
edit mode?

I am not sure if I should hide the combo by default and make visible in
'Add' mode or to leave it visible and hide in 'edit' mode.

I am using the MS switchboard to control form access, I am assuming it will
be on the forms 'onLoad' event ?

Regards
Si

Access 2007
 
J

Jeff Boyce

Controls on a form have properties. One of the properties is the .Visible
property... another is the .Enabled property.

Users sometimes get nervous when things disappear ... consider using
..Enabled to enable/disable the control, rather than disappearing it.

When you switch to "edit mode", how are you doing that?

If you have a command button, you could add code to that control to change
the .Enabled (or .Visible) property.

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.
 
S

SimonT

Hi Jeff,

Thanks for that.

As I mentioned I have a switchboard form that has buttons to select a form
to open, this particular form can choose from:

1 opens form in add mode
2 opens form in edit mode

So what I want is if the user is to add and record, the combo box is not
visible, (The combo box is only used to locate a record on the form, so it
only required in edit mode)

Regards
Si
 
J

Jeff Boyce

Hopefully one of the other readers can help. My last use of the Switchboard
feature was many years ago.

(If I had to think up a work-around, I might use code in the form's OnOpen
event that checked whether it was being opened for Edit or Add, then modify
the combobox's .Visible or .Enabled property...)

Good luck!

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.
 
D

Dirk Goldgar

SimonT said:
Hi Guys,

Does anyone know the syntax to hide a combo box on a form if it is opened
in edit mode?

I am not sure if I should hide the combo by default and make visible in
'Add' mode or to leave it visible and hide in 'edit' mode.

I am using the MS switchboard to control form access, I am assuming it
will be on the forms 'onLoad' event ?


You could use the form's Load event to check whether its recordset is empty.
That's not quite the same as knowing whether it was opened in add mode,
because you might just be opening it on an empty table, or a query that
returns no records. However, it might be good enough for your purposes.

'----- start of example code -----
Private Sub Form_Load()

Me.cboMyComboBox.Visible = _
(Me.Recordset.RecordCount <> 0)

End Sub
'----- end of example code -----
 

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