Include Field Value on button (1 Viewer)

gico1972

Registered User.
Local time
Today, 19:59
Joined
Oct 19, 2008
Messages
25
Is it possible to include a field value on a Button Caption?

The idea is to show a button "New Follow-up Records(5)"

The number in brackets would represent the number of records returned in the underlying query.

Any Help would be must appreciated.

Regards
 

namliam

The Mailman - AWF VIP
Local time
Today, 20:59
Joined
Aug 11, 2003
Messages
11,695
Yes you can fill the Caption of the button with any text you see fit...

Me.YourButtonName.Caption = "put anything here"
 

gico1972

Registered User.
Local time
Today, 19:59
Joined
Oct 19, 2008
Messages
25
Thanks for replying and I understand that.

What i want to do is also include in the caption the number of count records from a query.
Me.YourButtonName.Caption = "New Follow-up Records" + Record count if that makes sense.

Thanks
 

JANR

Registered User.
Local time
Today, 20:59
Joined
Jan 21, 2009
Messages
1,623
Something like this:

Code:
Option Compare Database
Option Explicit
Const DefaultCaption = "New Follow-up Records"
 
Private Sub CountRec()
Dim RecCount As Long
RecCount = Dcount("*", "tblSomething", "SomeField=Something") 
  If RecCount > 0 Then
     Me!Commandbtn.Caption = DefaultCaption & "(" & RecCount & ")"
  Else
     Me!Commandbtn.Caption = DefaultCaption
  End IF
End Sub

JR
 

namliam

The Mailman - AWF VIP
Local time
Today, 20:59
Joined
Aug 11, 2003
Messages
11,695
Personaly I wouldnt use DCount ...

Instead if you make sure you load all records in your form (using movelast and move first)
You can simply use RecordsetClone... Find this in the access help it has a 100% sample of how to do this.
 

Users who are viewing this thread

Top Bottom