Change Button Text before close

dgs2001

Board Regular
Joined
Apr 1, 2007
Messages
139
Hi All

First up I'm new to access but have a reasonable grip on excel and vba.

I have a database with one table which has a field called EVENT_DT which stores data like this
Code:
 23/05/2010 16:45

I also have a form called Form1 which has a command button called command2 with the following text on it "Click to save Results Last saved date : 21/05/2010"


What i would like to be able to do is have the date part of the button text auto update by looking for the newest date in the EVENT_DT Field either at database / form opening or before close.

Thanks for any pointers

Duncan
 

Some videos you may like

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,219
Office Version
  1. 365
Platform
  1. Windows
Duncan

Why not have a textbox on the form with it's control source being an expression that returns the last save date?

That would be easier to do than change the caption of a button - you wouldn't even need any code.
 

dgs2001

Board Regular
Joined
Apr 1, 2007
Messages
139
Hi Norrie

Thanks that sounds like a good idea, although i may not have explaned it properly.

For ease of use I am trying to display the last Event Date the database was updated to.

This will be different to the actual save date.

So the textbox would need to display the newest date from the EVENT_DT Field in "dd/mm/yyyy" format.

I'm thinking MAX, but am unsure how to work this into an expression.

Duncan
 

dgs2001

Board Regular
Joined
Apr 1, 2007
Messages
139
I think I'm getting there !!

I have created a text box and put this code into it
Code:
=IIf(IsNull([EVENT_DT]),Null,Max([EVENT_DT]))
however it returns #Name?

I think the
Code:
 MAX([EVENT_DT])
is wrong
 
Last edited:

dgs2001

Board Regular
Joined
Apr 1, 2007
Messages
139
More Progress !!

I have created a query which returns the required Newest date from the EVENT_DT Field

I have also created a list box which displays the results of the query.

so now all i need to do is either restrict the listbox to a single item or hide it and use the first (and only) item to populate my textbox.

I am stuck now so please help !!!

Duncan
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,219
Office Version
  1. 365
Platform
  1. Windows
Duncan

Try DMax.
 

Watch MrExcel Video

Forum statistics

Threads
1,122,961
Messages
5,599,061
Members
414,281
Latest member
Engjamal2021

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top