Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Enabling buttons

Status
Not open for further replies.

primagic

IS-IT--Management
Jul 24, 2008
476
GB
I have a subform which is view only. apart from two clickable buttons.

One button is open and the other is edit. the edit button enabled attribute is set to 'false'

What I want to do is, if one of the fields on the form matches another field on the form then enable the button, if not keep it disabled.

I have tried entering this code on the current event of the subform, the load event, the open event and still not working

Code:
 If Me.AddedBy = Me.CurrentUser Then
Me.btnEdit.Enabled = True
Else
Me.btnEdit.enabled = false
End if
 
It looks like you may need conditional formatting, but conditional formatting is not available for command buttons, perhaps you could add code to simply exit the sub if the condition is not met?
 
If one of the fields is on the subform then you need to change your syntax to check it.

Me.(subformName).(field)
 
Both fields are on the same form, so this is why I cant understand why the code is not working
 
Forgot to say, even if the condition is met, its not working. So if Field A does = Field B it doesnt enable the button
 
You must use conditional formatting on a continuous form and it is not possible to conditionally format control buttons.
 
How are ya primagic . . .\

Indications are the buttons are in the [blue]detail section[/blue] ... please verify this! If this is true you can replace the buttons with a textboxes, setting the following properties:
[ol][li]Special Effect [blue]Raised[/blue][/li]
[li]Back Style [blue]Normal[/blue][/li]
[li]Back Color [blue]same as the detail section or your choice[/blue][/li]
[li]The above simulates a button pretty well![/li][/ol]
This done, you can now use [blue]conditional formatting[/blue] to set the buttons aleviating the code in the [blue]On Current[/blue] event, which should be removed!

For the [blue]edit button[/blue] the conditional formating expression would look like:
Code:
[blue][AddedBy] = [CurrentUser][/blue]
[blue]Your Thoughts? . . .[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
I just created one button which opens the form and depending on the criteria will open the form either with allow edits or not. seems to work fine

thanks for all your tips
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top