diable button if no records exist

  • Thread starter Thread starter Tig
  • Start date Start date
T

Tig

hi,

i have a button on form A that opens form B.

How can i show the button as disabled on form A if there are no matching
records on form B?

Thanks in advance!

Tig
 
what happens if my form A is a continuous record?

e.g.

Col1 Col2
A 1 cmdbutton to open form B
B 2 cmdbutton (disabled - no matching records in form B)
C 3 cmdbutton to open form B

I understand "Me" works for 1 record. How about performing a function for
every record displayed on the continuous form?

Thanks,

Tig
 
Thanks to the wizardry of Stephen Lebans (http://www.lebans.com), there is a
sample of how to achieve this effect (somewhat) using ConditionalFormatting
here:
http://www.lebans.com/conditionalformatting.htm
A2K or Higher Only!

A2KConditionalFormatting.zip is a sample MDB demonstrating how to
programmatically setup Conditional Formatting to simulate:

1) Highlighting of the Current Row for a Form in Continuous or Datasheet
View

2) Highlighting of Alternate Rows for a Form in Continuous or Datasheet View

....but you can adapt it to your requirements.

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

Microsoft Access 2003 VBA Programmer's Reference
http://www.wiley.com/WileyCDA/WileyTitle/productCd-0764559036.html
 
Excellent, thanks !!

I have discovered another workaround. Make textboxes working like buttons
a combination of conditional formatting and procedure

Create a text box.

properties -->source:
=ScoreCount([ProductID])


Public Function ScoreCount(In_ProdID As Long) As String
Dim vScoreCount As Integer
vScoreCount = DCount("[ProductID]", "tblProductScore", _
"[ProductID] = " & In_ProdID)
If vScoreCount = 0 Then
ScoreCount = ""
Else
ScoreCount = "Click For Details"
End If
End Function

Then go to conditional formatting
format the textbox to "disable" if null and show text if equals to "Click
For Details"

if i make the button grey and raised, it halfs looks like a button.

of course when you mouse over it, it doesnot turn into a select pointer.....
oh well.

so for each record, ScoreCount will run and depending on the return value,
show / hide button !

Cheers!
 
Yes, your question has sparked a discussion about that very method.

I hope it works out for you.

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
---------------------------

Tig said:
Excellent, thanks !!

I have discovered another workaround. Make textboxes working like buttons
a combination of conditional formatting and procedure

Create a text box.

properties -->source:
=ScoreCount([ProductID])


Public Function ScoreCount(In_ProdID As Long) As String
Dim vScoreCount As Integer
vScoreCount = DCount("[ProductID]", "tblProductScore", _
"[ProductID] = " & In_ProdID)
If vScoreCount = 0 Then
ScoreCount = ""
Else
ScoreCount = "Click For Details"
End If
End Function

Then go to conditional formatting
format the textbox to "disable" if null and show text if equals to "Click
For Details"

if i make the button grey and raised, it halfs looks like a button.

of course when you mouse over it, it doesnot turn into a select
pointer..... oh well.

so for each record, ScoreCount will run and depending on the return value,
show / hide button !

Cheers!


Graham R Seach said:
Thanks to the wizardry of Stephen Lebans (http://www.lebans.com), there
is a sample of how to achieve this effect (somewhat) using
ConditionalFormatting here:
http://www.lebans.com/conditionalformatting.htm
A2K or Higher Only!

A2KConditionalFormatting.zip is a sample MDB demonstrating how to
programmatically setup Conditional Formatting to simulate:

1) Highlighting of the Current Row for a Form in Continuous or Datasheet
View

2) Highlighting of Alternate Rows for a Form in Continuous or Datasheet
View

...but you can adapt it to your requirements.

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

Microsoft Access 2003 VBA Programmer's Reference
http://www.wiley.com/WileyCDA/WileyTitle/productCd-0764559036.html
 
Back
Top