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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

On a Form enable of disable buttions 1

Status
Not open for further replies.

puforee

Technical User
Oct 6, 2006
741
US
I currently have a form that shows in continuous mode. So the screen shows multiple records. Each record has a button. When activated the button will run a query and open a second form (Pop-up/Modal). Right now when a button is clicked it first checks to see if the query to open the second form will return any data. If not, it shows a message stating nothing is available. If there is data to be returned it will show the second form with the data. The query to open the second form is based on a field on the main form to search for the correct data. This works well but......

My users want the button for each record to be disabled if there is no data to be shown...and they want it when the main form is opened. They don't want to click in a record to see if the button is available. Since I have multiple records showing how can I enable/disable each records button when the main form opens? Remembering the button for each record opens the second form that shows different data (if available) based a field in each record on the main form.

Thanks,
 
You could probably add a column to the record source that uses DCount() to count the records. Then use a text box rather than a button which allows setting conditional formatting. This text box can be raised and have a click event. Conditional formatting can set the enabled property.

Duane
Minnesota
Hook'D on Access
MS Access MVP 2001-2016
 
Duane,
I knew controlling the button would not work on a continuous form...change ones property changes all. Of course I remembered this after I send the question. Your idea is intriguing and I will give it a shot. I will get back to you with the results.

Thanks again for the many times you have helped.
 
Duan,
In my table I added a calculated field with DCount("Cust", "Filter for DA Classes") as the expression. But Access 2013 says I can't use it. Can you be more specific on how you would mechanize this. Am I supposed to be adding a field to my table, if so what kind and where does my DCount (shown above) go?

Thanks,
 
You would need to use a query as the record source and add the column there. You also need to have the DCount() filtered for each record. You haven't provided any details about the tables or relationships.

Duane
Minnesota
Hook'D on Access
MS Access MVP 2001-2016
 
Duane,
Thanks. I did go to a query that populates my main form and added my filtering query to it. I linked the two like fields and the added a column to do the DCount.

This produced the 0 or -1 out put based on the results of the DCount which is all I needed. Using that field on the form as a text box camouflaged as a button and set to hyperlink to turn the cursor to a hand, and wala it worked like a charm.

Thanks again,
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top