PC Review


Reply
Thread Tools Rate Thread

Button Caption help

 
 
Jim Brooks
Guest
Posts: n/a
 
      5th Feb 2010
Hi to all I require help for what maybe a simple problem. I have a form
frmPettyCash and on the form are 3 buttons Cmd1, Cmd2 and Cmd3 which open the
spending reports for 3 employees. There is a table tblEmployees with fields
EmployeeID and EmployeeName with the 3 employee names. What I would like to
do is link the EmployeeNames to the button caption ie Employee 1 to
Cmd1.Caption, Employee2 to Cmd2.Caption etc. so that in the future if I
change an employee name in the employee table the caption on the
corresponding button will change also. Any help greatly appreciated.
Thanks in advance
Jim Brooks

 
Reply With Quote
 
 
 
 
KARL DEWEY
Guest
Posts: n/a
 
      5th Feb 2010
Why not use text box instead of label and use DLookup as source?

--
Build a little, test a little.


"Jim Brooks" wrote:

> Hi to all I require help for what maybe a simple problem. I have a form
> frmPettyCash and on the form are 3 buttons Cmd1, Cmd2 and Cmd3 which open the
> spending reports for 3 employees. There is a table tblEmployees with fields
> EmployeeID and EmployeeName with the 3 employee names. What I would like to
> do is link the EmployeeNames to the button caption ie Employee 1 to
> Cmd1.Caption, Employee2 to Cmd2.Caption etc. so that in the future if I
> change an employee name in the employee table the caption on the
> corresponding button will change also. Any help greatly appreciated.
> Thanks in advance
> Jim Brooks
>

 
Reply With Quote
 
John Spencer
Guest
Posts: n/a
 
      5th Feb 2010
In the load event of the form you could set the caption on each button based
on looking up the relevant value.

If you have three employee records with these two fields you should be able to
do it.
Employee Table
EmployeeName
ButtonNumber (1,2,3) for the three buttons

In the Form's load event you would need three statements

Me.Cmd1.Caption= DLookup("EmployeeName","EmployeeTable","ButtonNumber=1")
Me.Cmd2.Caption= DLookup("EmployeeName","EmployeeTable","ButtonNumber=2")
Me.Cmd3.Caption= DLookup("EmployeeName","EmployeeTable","ButtonNumber=3")

Although I think this would not be the best way to handle this situation, it
can be done. I would rather have a control (a combobox or a listbox) that
listed the employees and then have code in the after update event of the
control or the click event of a button that does whatever the buttons are
doing now based on a value in the combobox/listbox.

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County

KARL DEWEY wrote:
> Why not use text box instead of label and use DLookup as source?
>

 
Reply With Quote
 
Jim Brooks
Guest
Posts: n/a
 
      6th Feb 2010
Thanks to all for the advice I removed the buttons and replaced them with
list boxes and used the onclick event to load my reports and it works fine.
Still learning.
Thanks again
regards Jim Brooks

"John Spencer" wrote:

> In the load event of the form you could set the caption on each button based
> on looking up the relevant value.
>
> If you have three employee records with these two fields you should be able to
> do it.
> Employee Table
> EmployeeName
> ButtonNumber (1,2,3) for the three buttons
>
> In the Form's load event you would need three statements
>
> Me.Cmd1.Caption= DLookup("EmployeeName","EmployeeTable","ButtonNumber=1")
> Me.Cmd2.Caption= DLookup("EmployeeName","EmployeeTable","ButtonNumber=2")
> Me.Cmd3.Caption= DLookup("EmployeeName","EmployeeTable","ButtonNumber=3")
>
> Although I think this would not be the best way to handle this situation, it
> can be done. I would rather have a control (a combobox or a listbox) that
> listed the employees and then have code in the after update event of the
> control or the click event of a button that does whatever the buttons are
> doing now based on a value in the combobox/listbox.
>
> John Spencer
> Access MVP 2002-2005, 2007-2010
> The Hilltop Institute
> University of Maryland Baltimore County
>
> KARL DEWEY wrote:
> > Why not use text box instead of label and use DLookup as source?
> >

> .
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Set Button Caption Nigel Microsoft Excel Programming 1 2nd Feb 2009 09:58 PM
blinking button caption dimpie Microsoft Access VBA Modules 1 25th Mar 2008 06:42 PM
Created custom caption bar - need help with caption button positio =?Utf-8?B?TWFyaXVzSQ==?= Microsoft Dot NET Framework Forms 0 28th Jun 2005 08:21 AM
Button Caption? MJJ Microsoft Access 1 6th Jun 2004 01:49 AM
Caption of a button Dr_Phil Microsoft Excel Programming 4 4th May 2004 09:13 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:32 PM.