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

Displaying Created or Modified Date on a Switchboard 1

Status
Not open for further replies.

cabbey77

Technical User
Aug 6, 2004
68
0
0
US
Hello all,

You are all always so helpful, I have a new question.

I want to post a notice on the main switchboard of my db notifying users of the last time 2 of the tables were created or modified. What is the most efficient way to do this?

Cheers,

C
 
Code:
Public Enum DateChoice
 created = 0
 Modified = 1
End Enum

Public Function GetTableDate(TableName As String, Choice As DateChoice) As Date
  Dim tdf As TableDef
  Dim db As DAO.Database
  Set db = CurrentDb
  For Each tdf In db.TableDefs
    If tdf.Name = TableName Then
      Set tdf = db.TableDefs(TableName)
      Exit For
    End If
  Next tdf
  If tdf Is Nothing Then
    MsgBox "No table named " & TableName & "."
  Else
    If Choice = created Then
      GetTableDate = tdf.DateCreated
    ElseIf Choice = Modified Then
      GetTableDate = tdf.LastUpdated
    End If
  End If
End Function
So you could simply have textboxes with controlsources like

=GetTableDate("YourTableName",0)
=GetTableDate("YourTableName",1)

Or you can call the function in code. If you call it in code you can actually use the enumerated type and call it like
GetTableDate("YourTableName",Created)
or
GetTableDate("YourTableName",Modified)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top