Startup and forms caption

L

lmv

In the caption of a form I have whatever it is in the caption field naming
the form ie: Legend, search. edit info etc
I have different databases for different areas so I want it to pull
additional info into the caption.
I know how to change the caption (see following code) BUT I don't know how
to add the info in the caption field on the fly (ie "Legend", edit info"
etc) to that code. I don't want to hard code the words.

I don't know what the code is for the caption lookup.
I also want the DB to startup with the code
= DLookup("[CongName]", "[tblCongInfo]")

I don't know how to do it other than hardcoding it into the startup is there
a way?

Private Sub Form_Activate()
On Error GoTo ProcError

' Change the form's caption!
Me.Caption = DLookup("[CongName]", "[tblCongInfo]")

ExitProc:
Exit Sub
ProcError:
MsgBox "Error " & Err.Number & ": " & Err.Description
Resume ExitProc

End Sub

thanks!!
 
R

Rastro

To make the change you need the event. It can be form_activate or any other
but you need one.
After this I don't see clear what you need.
For search of title you need a table, field and a criteria. Once you solve
this you have the additional info.
'This suppose that you have a table that has two fields: "FieldForm" and
"FieldwithAddinfo", and the rows contain the forms names and their own
additional information

strAddInfo=DLookUp(FieldwithAddInfo, Table, FieldForm=Me.Caption)

The next step is to join both strings:
Me.Caption=Me.Caption & " - " & strAddInfo

I'm not sure that it is what you were looking for but here it is

Rastro
 
L

lmv

thank you that is exactly what I needed!

Rastro said:
To make the change you need the event. It can be form_activate or any other
but you need one.
After this I don't see clear what you need.
For search of title you need a table, field and a criteria. Once you solve
this you have the additional info.
'This suppose that you have a table that has two fields: "FieldForm" and
"FieldwithAddinfo", and the rows contain the forms names and their own
additional information

strAddInfo=DLookUp(FieldwithAddInfo, Table, FieldForm=Me.Caption)

The next step is to join both strings:
Me.Caption=Me.Caption & " - " & strAddInfo

I'm not sure that it is what you were looking for but here it is

Rastro

lmv said:
In the caption of a form I have whatever it is in the caption field naming
the form ie: Legend, search. edit info etc
I have different databases for different areas so I want it to pull
additional info into the caption.
I know how to change the caption (see following code) BUT I don't know how
to add the info in the caption field on the fly (ie "Legend", edit info"
etc) to that code. I don't want to hard code the words.

I don't know what the code is for the caption lookup.
I also want the DB to startup with the code
= DLookup("[CongName]", "[tblCongInfo]")

I don't know how to do it other than hardcoding it into the startup is
there
a way?

Private Sub Form_Activate()
On Error GoTo ProcError

' Change the form's caption!
Me.Caption = DLookup("[CongName]", "[tblCongInfo]")

ExitProc:
Exit Sub
ProcError:
MsgBox "Error " & Err.Number & ": " & Err.Description
Resume ExitProc

End Sub

thanks!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top