|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
I have created a form, which has a number of command buttons on it. However, i dont want all the buttons to be able to be pressed until the selected information has been entered. For example, where a member decides to pay by their membership by direct debit - the bank details button should become active. If the condition is not met, it should remain inactive.
is it possible to 'grey out' command buttons until information has been entered into access? any information about how it is done would be massively appreciated. Thompson |
|
#2
|
|||
|
|||
|
The easiest way would be to set the command buttons Enabled property to NO. Then in the After Update event of your controls you would enable those buttons you want to have the user to use.
CommandButton.Enabled = True lwells |
|
#3
|
|||
|
|||
|
That helped enormously, and the command buttons work, however, is there a way of writing an if statement into it, so that when a family member is selected from a combo box (rather than any other value) the button can appear?
|
|
#4
|
|||
|
|||
|
Sure, just specify what that value is in your if statement.
If combobox = "FamilyMember" Then CommandButton.Enable = True Else CommandButton.Enabled = False End If Just specify what the text value of your combo box is to determine whether to enable your command button. You will need to use the bound column of the combobox or specify which column to use. lwells |
|
#5
|
|||
|
|||
|
Thats worked a treat, thanks a lot for the help.
|
|
#6
|
|||
|
|||
|
Text boxes
is it possible to be able to grey out the command buttons, but as soon information is entered into both of the two required fields the buttons are activated. my code at the moment is as follows:
Sub JobButtonEnable() If jobLocation.[Value] <> "" And jobContact.[Value] <> "" Then [AddRecord].[Enabled] = True [SaveRecord].[Enabled] = True Else [AddRecord].[Enabled] = False [SaveRecord].[Enabled] = False End If End Sub Then i use onChange to call the macro, but you always have to click out of the text box for it to detect that the value is more than null. I would like it so the user enters information into either the jobLocation or jobContact text box, then as soon as they begin typing data into the other box it activates the buttons, rather than when they tab out or click out of the text box, as the other information is not always required. The closest remedy i have to my problem is to use a onTimer() with the interval being something quick like 1ms, so as soon as the user enters anything into the text box it is activated. Unfortunately this causes the buttons to flicker, so that really isnt the best solution unless it has to be. Any ideas will be appreciated! |
|
#7
|
|||
|
|||
|
Text Boxes
Why don't you try putting code like below so that the user is put into the field you choose no matter what field they started in.
Try this it should work:- Private Sub Form_Open(Cancel As Integer) Forms!Form1!SaveRecord.Enabled = False Forms!Form1!AddRecord.Enabled = False End Sub Private Sub Joblocation_Enter() If (Eval("[Forms]![Form1]![Jobcontact] Is Not Null")) Then Forms!Form1!SaveRecord.Enabled = True Forms!Form1!AddRecord.Enabled = True Else DoCmd.GoToControl "Jobcontact" End If End Sub Hope this helps! |
![]() |
| Viewing: Dev Articles Community Forums > Databases > Microsoft Access Development > Greying out command buttons |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|