Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / New Users / October 2007

Tip: Looking for answers? Try searching our database.

hide cmd buttons untill selection is made in cbo box

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Chad - 03 Oct 2007 10:36 GMT
Hello, I have a question and I have no clue on how to do it. I have a combo
box named cboEmployees and this is what I want to do is if I dont select
anything from the list in the cboEmployees then the two buttons named
cmdIndividualEmployeeData and cmdIndividualEmployeePercent will not show. Now
I want the buttons "cmdIndividualEmployeeData and
cmdIndividualEmployeePercent" to be visable but whited out and not clickable
but if I select something from the cboEmployees menu the they will show
regularly. I have this on a database section already but it was pre-made and
I cant figure out how to do it. Here is the code from the other database I
think that makes it work and with my names in it but it doesnt work for me in
the new database. What and where am I missing code? Thanks!

Private Sub cboEmployees_AfterUpdate()
If IsNull(Me.cboEmployees) Then
 Me.TimerInterval = 0
 Me.FramePropertyValue.Enabled = False
Else
 Me.FramePropertyValue.Enabled = True
End If
End Sub

Private Sub FramePropertyValue_AfterUpdate()
If Me.ActiveControl <> 0 Then
 Me.cmdIndividualEmployeeData.Enabled = True
 Me.cmdIndividualEmployeeData.ForeColor = 0
Else
 Me.cmdIndividualEmployeeData.Enabled = False
 Me.cmdIndividualEmployeeData.ForeColor = 255
End If
End Sub

Signature

Newbies need extra loven.........

Tore - 03 Oct 2007 18:45 GMT
On your access form make sure that your combobox has a name. You do this by
opening the form in design mode, then double-click on the combobox (or right
click and select properties) to open properties. Select "Other" and give the
combobox a name, for instance "cboEmploees".

Then, still within properties, go to "events" and select (double click)
"after update" event. This will open the visual basic editor and insert an
empty procedure Private Sub cboEmployees_AfterUpdate() This will ensure that
you have created a procedure that is triggered by your combobox. To test it,
you can write a line of code within the procedure:

Private Sub cboEmployees_AfterUpdate()

Msgbox("Procedure runs ok")

End sub

If the msgbox is displayed when your select something from your combobox
then the procedure runs ok.

To add some of the logic you request you can substitute the msgbox line with
the following:

If isnull(Me.cboEmployees.column(0)) Then

Me.cmdIndividualEmployeeData.enabled = False

Me.cmdIndividualEmployeePercent.enabled = False

Else

Me.cmdIndividualEmployeeData.enabled = True

Me.cmdIndividualEmployeePercent.enabled = True

End if

I don't know if your combobox has more than one column. Column(0),
Column(1), Column(2) etc selects the actual columns of your combobox.

Regards

Tore

> Hello, I have a question and I have no clue on how to do it. I have a
> combo

> box named cboEmployees and this is what I want to do is if I dont select

> anything from the list in the cboEmployees then the two buttons named

> cmdIndividualEmployeeData and cmdIndividualEmployeePercent will not show.
> Now

> I want the buttons "cmdIndividualEmployeeData and

> cmdIndividualEmployeePercent" to be visable but whited out and not
> clickable

> but if I select something from the cboEmployees menu the they will show

> regularly. I have this on a database section already but it was pre-made
> and

> I cant figure out how to do it. Here is the code from the other database I

> think that makes it work and with my names in it but it doesnt work for me
> in

> the new database. What and where am I missing code? Thanks!

> Private Sub cboEmployees_AfterUpdate()

> If IsNull(Me.cboEmployees) Then

> Me.TimerInterval = 0

> Me.FramePropertyValue.Enabled = False

> Else

> Me.FramePropertyValue.Enabled = True

> End If

> End Sub

> Private Sub FramePropertyValue_AfterUpdate()

> If Me.ActiveControl <> 0 Then

> Me.cmdIndividualEmployeeData.Enabled = True

> Me.cmdIndividualEmployeeData.ForeColor = 0

> Else

> Me.cmdIndividualEmployeeData.Enabled = False

> Me.cmdIndividualEmployeeData.ForeColor = 255

> End If

> End Sub

> Newbies need extra loven.........
Klatuu - 03 Oct 2007 18:52 GMT
You will need to put code in two places.  To ensure they are disabled for
each record, you will need to disable them in the form Current event.

   With Me
       .cmdIndividualEmployeeData.Enabled = False
       .cmdIndividualEmployeePercent = False
   End With

Then to turn them on use the AfterUpdate event of the Combo box

   With Me
       .cmdIndividualEmployeeData.Enabled = True
       .cmdIndividualEmployeePercent = True
   End With

Signature

Dave Hargis, Microsoft Access MVP

> Hello, I have a question and I have no clue on how to do it. I have a combo
> box named cboEmployees and this is what I want to do is if I dont select
[quoted text clipped - 26 lines]
> End If
> End Sub
Chad - 03 Oct 2007 23:57 GMT
I have tried this code already and its something like what I want to do but
not quite. I dont want the buttons to be invisable untill I select something
in the combo box I want them to be visable but whited out and non clickable
untill a selection is made. Any ideas? Thanks!!!
Signature

Newbies need extra loven.........

> You will need to put code in two places.  To ensure they are disabled for
> each record, you will need to disable them in the form Current event.
[quoted text clipped - 41 lines]
> > End If
> > End Sub
Chad - 04 Oct 2007 08:40 GMT
I got it working the way I wanted. I had to set the button(s) I wanted whited
out to event Enabled= No and I used this code...

Private Sub cboEmployees_AfterUpdate()

If Me.cboEmployees <> 0 Then
 cmdIndividualEmployeeData.Enabled = True
cmdIndividualEmployeePercent.Enabled = True
Else
 cmdIndividualEmployeeData.Enabled = False
 cmdIndividualEmployeePercent.Enabled = False
End If

End Sub
Signature

Newbies need extra loven.........

> I have tried this code already and its something like what I want to do but
> not quite. I dont want the buttons to be invisable untill I select something
[quoted text clipped - 46 lines]
> > > End If
> > > End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.