Dynamic Form Caption

G

Guest

Hello-

I am trying to set field captions based on a query. So when an individual
opens up a form (datasheet view, form view, etc.) the field captions are
generated based on some predefined criteria.

Field Name: Metric 1
Field Caption: [based on query]

Does anyone know this can be done?
 
J

Jeff Boyce

What query? What does [Field Name] have to do with this?

Yes, it is possible to have a table of "settings" and a function that
returns a particular setting value and code behind the form's OPEN event
that calls the function to return the Caption value. How's your comfort
level with creating VBA?

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
G

Guest

Sorry for the delay in getting back to you. The query would be based on a
settings table (settings shoudl be different per job). So, for example, the
caption on "metric1" will be different if the record is related to job1 or
job3...

I am not very well versed with VBA but if you know of any examples or
similar code snippets I am sure I can figure it out.

Your help is greatly appreciated.

Jeff Boyce said:
What query? What does [Field Name] have to do with this?

Yes, it is possible to have a table of "settings" and a function that
returns a particular setting value and code behind the form's OPEN event
that calls the function to return the Caption value. How's your comfort
level with creating VBA?

Regards

Jeff Boyce
Microsoft Office/Access MVP


dmericksen said:
Hello-

I am trying to set field captions based on a query. So when an individual
opens up a form (datasheet view, form view, etc.) the field captions are
generated based on some predefined criteria.

Field Name: Metric 1
Field Caption: [based on query]

Does anyone know this can be done?
 
R

Ron2006

Here is an example of code used to change the bold and font colors on a
form that lists the weeks of a month and highlights the one for the
current control week.

If WeekNumber > 0 And WeekNumber < 7 Then
Select Case WeekNumber
Case 1
Me.WhichW1Start.FontBold = True
Me.WhichW1Start.BackColor = 16711680
Me.WhichW1Start.ForeColor = 16777215
Me.WhichW1End.FontBold = True
Me.WhichW1End.BackColor = 16711680
Me.WhichW1End.ForeColor = 16777215
Me.Command35.SetFocus
Case 2
Me.WhichW2Start.FontBold = True
Me.WhichW2Start.BackColor = 16711680
Me.WhichW2Start.ForeColor = 16777215
Me.WhichW2End.FontBold = True
Me.WhichW2End.BackColor = 16711680
Me.WhichW2End.ForeColor = 16777215
Me.Command36.SetFocus
End Select
End If

It is executed in the OnCurrent event. Caption and anything else that
you see in the format tab for a field are accessible and addressable.

This form was not bound so did not progress through records. If you
have one that does go through records AND the captions, etc can change
then you have to code all possibities. The default condition will only
exist on the open , from then on you have to assign the default
captions, etc yourself.
 

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