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

2 (hopfully easy) vba questions 1

Status
Not open for further replies.

policechiefwiggum

Programmer
Mar 19, 2006
48
GB
Hi All,

I'm trying to teach myself SQL & VBA.

i've built a database that i'm pretty happy with but i want to do 2 things that i just cant figure out.
1)i want to display just the year, but i want it to update automatically (as part of the copyright text i've added)i've tried
Code:
tday = format(date, yyyy)
but this does nothing.

2) i have user logins and would like to have a clock on one of the forms, i've found a few clocks on the internet but cant figure out how to make them work.

can anyone give me some pointers?

cheers
 
I assume there is more code then that, but the problem you are showing is probably because you do not have quotes around the yyyy's

Try this

Code:
Private Sub Command0_Click()
Dim tday As String
   tday = Format(Date, "yyyy")
   MsgBox tday
End Sub
 
You can get a simple digital clock on the form if you add a label named lblClock and add code like this:
Code:
Private Sub Form_Load()
  '-- Initialise the clock and update every second
  TimerInterval = 1000
  lblClock.Caption = Time()
End Sub

Private Sub Form_Timer()
  '-- Refresh the clock display
  lblClock.Caption = Time()
End Sub

Geoff Franklin
 
You may also simply use this:
=Year(Date())

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top