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

Create a module to set forms Caption

Status
Not open for further replies.

jcmv007

Technical User
Nov 1, 2001
88
US
Is it posible to create a module that sets a form's Caption?
All forms will have the control: txtTitle which would contain the form's Title, but this title would have to include the date. Up to now I have this code
Code:
Function SetTitle()
On Error Resume Next
    Screen.ActiveForm.Caption = Screen.ActiveControl!txtTitle & " " & Now()
End Function

What is the code need to make this into a working module?

Using Access 2002 and Windows XP - SP1.


James
 
Hi jcmv007,

This is one way to do it, paste this into a Standard Module:

Public Function SetTitle(strForm As String)
Dim frm As Form
Set frm = Forms(strForm)
If Not IsNull(frm!txtTitle) Then
frm.Caption = frm!txtTitle & " " & Now()
End If
End Function

Paste this into the Load event of a Form:

SetTitle (Me.Name)

Bill

 
Bill,

Thanks it works great!



James
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top