Enabling/disabling command button based on DCount

H

hermanko

Hi,

On a form based on a query, I have a textbox with DCount function to
display the number of records in the underlying query. The form
displays all the records with a duplicate field "Fund Name". I have a
command button that triggers an action query ,however I want to have
that command button disabled IF the form displays zero records. In this
case, the user can only click on Cancel to go back. If there are
presently records then that button should be enabled. My event
procedure is:

If IsNull(Me!txt_dupcount3) Then
Me!cmd_remove3.Enabled = False
Else
Me!cmd_remove3.Enabled = True
End If

where txt_dupcount3 is the name of the textbox containing my DCount
function, and cmd_remove3 is my button.

I also a Yes/No field with checkboxes. My other approach would be to
have the form load with the button already disabled by default....and
once any ONE checkbox is selected it will enable the button (implying
that there are existing records displayed).

If possible, can someone help me please with either approach? Thanks!!
Herman
 
R

Ron2005

What event procedure.............?

Seems that there must be a subform somewhere here, or are the field and
button on header/footer parts of the form?

I believe the onCurrent event for the form would be where you want to
put it. And keep the logic the same.

Ron
 

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

Similar Threads

Access Dcount (multiple criteria) 3
dcount 1
DCount problem redux 4
Still struggling with DCount 8
Access MS Access DCount function problem 0
Hiding a button based on a value in a table 1
Disable/Enable Command Button 3
DCount Error 2001 1

Top