Get text box contents from a report

W

Wigi

Hello all

I would like to know how I can get the contents of a text box from a report,
and fire a msgbox with that result.

The report is called rep_winst per maand (so spaces included), the name of
the text box is Sum Of winstbetaald (spaces included).

[Upon closing the Access DB, I would like to write that result to a text
file.]

Thanks in advance.
 
E

Evi

So long as the text box is not in a subreport, Code the OnClose Event of the
report as follows

Private Sub Report_Close()
Dim MyVal As Double
MyVal = Me.[Sum Of winstbetaald]
MsgBox MyVal
Open "MyVal.txt" For Output As #1
Write #1, MyVal
Close #1
End Sub

It writes the contents of your textbox to a text file called MyVal which
will be in the same folder as your db

Evi
 
W

Wigi

Thank you Evi, this works nicely.

I still have one problem, though.

The report shows the results of a query. There are monthly values in the
query for 3 categories, from January 2007 until May 2008. Each month the
query has 3 more lines. The text box gives me the value for November 2007
(don't know why).

Can I have the value for the most recent month?

Thank you.

--
Wigi
http://www.wimgielis.be = Excel/VBA, soccer and music


Evi said:
So long as the text box is not in a subreport, Code the OnClose Event of the
report as follows

Private Sub Report_Close()
Dim MyVal As Double
MyVal = Me.[Sum Of winstbetaald]
MsgBox MyVal
Open "MyVal.txt" For Output As #1
Write #1, MyVal
Close #1
End Sub

It writes the contents of your textbox to a text file called MyVal which
will be in the same folder as your db

Evi

Wigi said:
Hello all

I would like to know how I can get the contents of a text box from a report,
and fire a msgbox with that result.

The report is called rep_winst per maand (so spaces included), the name of
the text box is Sum Of winstbetaald (spaces included).

[Upon closing the Access DB, I would like to write that result to a text
file.]

Thanks in advance.
 
E

Evi

The code is for a text box in your report footer.
If the text box (Sum Of winstbetaald) appears multiple times in your report
then the value which
appears in your message box will be the last value listed.

Is it in a group footer? Or is it in a subreport

If in a footer, how is that footer grouped, by which field name and by which
datatype (by a date, a number, or by text?)

Evi




Wigi said:
Thank you Evi, this works nicely.

I still have one problem, though.

The report shows the results of a query. There are monthly values in the
query for 3 categories, from January 2007 until May 2008. Each month the
query has 3 more lines. The text box gives me the value for November 2007
(don't know why).

Can I have the value for the most recent month?

Thank you.

--
Wigi
http://www.wimgielis.be = Excel/VBA, soccer and music


Evi said:
So long as the text box is not in a subreport, Code the OnClose Event of the
report as follows

Private Sub Report_Close()
Dim MyVal As Double
MyVal = Me.[Sum Of winstbetaald]
MsgBox MyVal
Open "MyVal.txt" For Output As #1
Write #1, MyVal
Close #1
End Sub

It writes the contents of your textbox to a text file called MyVal which
will be in the same folder as your db

Evi

Wigi said:
Hello all

I would like to know how I can get the contents of a text box from a report,
and fire a msgbox with that result.

The report is called rep_winst per maand (so spaces included), the name of
the text box is Sum Of winstbetaald (spaces included).

[Upon closing the Access DB, I would like to write that result to a text
file.]

Thanks in advance.
 

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