Enabling or Disabling Button in Details of Continuous Form

tomd1969

New member
Local time
Today, 10:51
Joined
Jan 11, 2012
Messages
7
This is a bit complicated, and I'm not sure if I can explain it correctly.

I have a continuous form from which a user can look up a SKU and get to the forms that apply to that product number at that point in time, to sort of get an idea of the history of that SKU (each detail of the continuous form corresponds to a specific date that a count was done on that product). Sometimes, there is a recount form that is available for that cycle count, and I have a command button in the details area so that the form relevant to the count performed on a particular date can be viewed. However, if the user clicks this button and there is no form available for this particular date/SKU combination, all kinds of errors pop up, and I need to avoid this if possible.

This is determined by whether or not there is a value in the 'Count1' field of the appropriate detail. I have the following code in the "Form_Load" event of the form:

Code:
Private Sub Form_Load()
    If Application.Nz(Me.Count1, "") = "" Then
        Me.OpenRecount.Enabled = False
    Else
        Me.OpenRecount.Enabled = True
    End If
End Sub

The problem is that this is an all-or-nothing solution. If any of the Count1 boxes are null, then all of the resulting "OpenRecount" controls are disabled. "OpenRecount" only gets enabled if all the Count1s in all the details are not null.

This is not what I wanted: I want the OpenRecount button enabled only in the detail groups where there is a recount form available, not all-or-nothing.

Anyone have any ideas?
 
That type of code really doesn't work in a continuous or datasheet form, as you've discovered. The easiest method is Conditional Formatting.
 
And Conditional Formatting is not available on a Command Button. :(
 
What I did instead was fix the form that was causing the problem so that it would present a blank form instead of erroring out. :o

Not as elegant as I would like, but it works.

Thanks for your assistance.
 
Sorry, I missed that it was a button.
 
But it is on a Textbox, and you can use the OnClick event of a Textbox to act as a Command Button.

Linq ;0)>

Yeah, that did the trick. Before calling up the form, I look at Count1 to make sure that it's not Null and used the Conditional Format of the TextBox to give a visual cue that it is not available.

It looks a little odd, but it works. Thanks!
 

Users who are viewing this thread

Back
Top Bottom