add a control name in the report caption

M

mhmaid

in the report properties , there is caption, which will be show on the top
left of the screen when open rpt preview. is it possible to include a control
name in this caption like this

invoices list for batch number & [batchnumber]

to get it like this
invoices list for batch number 399
 
M

Marshall Barton

mhmaid said:
in the report properties , there is caption, which will be show on the top
left of the screen when open rpt preview. is it possible to include a control
name in this caption like this

invoices list for batch number & [batchnumber]

to get it like this
invoices list for batch number 399


No. You need to use a little VBA code in an event
procedure:
Me.Caption = "invoices list for batch number " _
& [batchnumber]

Try using the Activate event or the report header section's
Format event.
 
M

mhmaid

thank you for response and help
i have tested it ,but it workd with some controls only
what could be the reason
i have for example two controls
caseid
and
batchid
both are numbers
it workd with the first
but not worked with the second.

Marshall Barton said:
mhmaid said:
in the report properties , there is caption, which will be show on the top
left of the screen when open rpt preview. is it possible to include a control
name in this caption like this

invoices list for batch number & [batchnumber]

to get it like this
invoices list for batch number 399


No. You need to use a little VBA code in an event
procedure:
Me.Caption = "invoices list for batch number " _
& [batchnumber]

Try using the Activate event or the report header section's
Format event.
 
M

Marshall Barton

Shouldn't be too difficult. What did you try?
--
Marsh
MVP [MS Access]

i have tested it ,but it workd with some controls only
what could be the reason
i have for example two controls
caseid
and
batchid
both are numbers
it workd with the first
but not worked with the second.

Marshall Barton said:
mhmaid said:
in the report properties , there is caption, which will be show on the top
left of the screen when open rpt preview. is it possible to include a control
name in this caption like this

invoices list for batch number & [batchnumber]

to get it like this
invoices list for batch number 399


No. You need to use a little VBA code in an event
procedure:
Me.Caption = "invoices list for batch number " _
& [batchnumber]

Try using the Activate event or the report header section's
Format event.
 
M

mhmaid

I have tried this
Private Sub ReportHeader_format(Cancel As Integer, formatCount As Integer)

Me.Caption = "invoices list for batch number " & [BatchId]


End Sub
but i am getting a run time erro 2465

cant find the field batchid
although it is there

but if i put inseated of it the field Caseid, which is also a number field,
it work




Marshall Barton said:
Shouldn't be too difficult. What did you try?
--
Marsh
MVP [MS Access]

i have tested it ,but it workd with some controls only
what could be the reason
i have for example two controls
caseid
and
batchid
both are numbers
it workd with the first
but not worked with the second.

Marshall Barton said:
mhmaid wrote:

in the report properties , there is caption, which will be show on the top
left of the screen when open rpt preview. is it possible to include a control
name in this caption like this

invoices list for batch number & [batchnumber]

to get it like this
invoices list for batch number 399


No. You need to use a little VBA code in an event
procedure:
Me.Caption = "invoices list for batch number " _
& [batchnumber]

Try using the Activate event or the report header section's
Format event.
 
M

Marshall Barton

mhmaid said:
I have tried this
Private Sub ReportHeader_format(Cancel As Integer, formatCount As Integer)

Me.Caption = "invoices list for batch number " & [BatchId]


End Sub
but i am getting a run time erro 2465

cant find the field batchid
although it is there

but if i put inseated of it the field Caseid, which is also a number field,
it work

I don't see how you could get an error anything like that
from that one line of code. If you remove the line of code,
does the error go away?

If not, double check that you do not have some other place
in the report that has a misspelled variation of the firld
name and that the field is really in the report's record
source table/query.
 
M

mhmaid

the field is there in the report source
but now i have tried adding a new column /field to the report for the
batchid, this solved the problem, but i dont know what is the relation
between the two things

thanks

Marshall Barton said:
mhmaid said:
I have tried this
Private Sub ReportHeader_format(Cancel As Integer, formatCount As Integer)

Me.Caption = "invoices list for batch number " & [BatchId]


End Sub
but i am getting a run time erro 2465

cant find the field batchid
although it is there

but if i put inseated of it the field Caseid, which is also a number field,
it work

I don't see how you could get an error anything like that
from that one line of code. If you remove the line of code,
does the error go away?

If not, double check that you do not have some other place
in the report that has a misspelled variation of the firld
name and that the field is really in the report's record
source table/query.
 
M

Marshall Barton

mhmaid said:
the field is there in the report source
but now i have tried adding a new column /field to the report for the
batchid, this solved the problem, but i dont know what is the relation
between the two things


Ahhh, I think I see. You had a field in the report's record
source, but no control that referenced the field. The only
use of the field was in the line of VBA code. Right?

If so, then that is a known issue. Access reports (unlike
forms) try to optimize data retrieval by only fetching data
that is used in a control's ControlSource somewhere in the
report. Your idea of adding a (hidden?) control bound to
the field is exactly the right way to resolve your problem.
 

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