READ A Field in a report and copy the contents

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Can Someone help me please. I am trying to learn VBA and it is spanking me. I am writting a code that opens a form named MYFORM. I do this with do comand. I have a field in the form that I would like to read its value and pass it to the save report command. The value of the field is used to name the report. The field is unbound and is generated on the form but not stored in a table. If you can show me how I can tell the user prior to asigning the contents to the report name as to what the contants of the feild are I would greately appreciate that too
 
Musiwa,

The general syntax for referring to form controls is:
Forms!formname!controlname

So if you want to get teh value of a form control, you would do it like so:
Dim vMyValue As Variant 'Cause I don't know the datatype

vMyValue = Forms!frmMyForm!ctlMyControl

If you can be a bit more specific about how you want to pass this value on,
we might be able to offer a bit more help.

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

Musiwa said:
Can Someone help me please. I am trying to learn VBA and it is spanking
me. I am writting a code that opens a form named MYFORM. I do this with do
comand. I have a field in the form that I would like to read its value and
pass it to the save report command. The value of the field is used to name
the report. The field is unbound and is generated on the form but not stored
in a table. If you can show me how I can tell the user prior to asigning the
contents to the report name as to what the contants of the feild are I would
greately appreciate that too.
 
----- Graham R Seach wrote: ----

Musiwa

The general syntax for referring to form controls is
Forms!formname!controlnam

So if you want to get teh value of a form control, you would do it like so
Dim vMyValue As Variant 'Cause I don't know the datatyp

vMyValue = Forms!frmMyForm!ctlMyContro

If you can be a bit more specific about how you want to pass this value on
we might be able to offer a bit more help

Regards
Graham R Seac
Microsoft Access MV
Sydney, Australi

Musiwa said:
Can Someone help me please. I am trying to learn VBA and it is spankin
me. I am writting a code that opens a form named MYFORM. I do this with d
comand. I have a field in the form that I would like to read its value an
pass it to the save report command. The value of the field is used to nam
the report. The field is unbound and is generated on the form but not store
in a table. If you can show me how I can tell the user prior to asigning th
contents to the report name as to what the contants of the feild are I woul
greately appreciate that too
I appologise for the shabby information I gave. I do appreciate your answer though. This is the code I have so far and a little explanation of what I want to do
Function SINGPTVsav (
Dim ChartName as a string 'This variable holds the string that is read from the for
On Error go to SINGPTVsav_Er
Docmd.OpenForm "VisitPages",acNormal, "", "", , acNormal 'This opens the form with the field I wan
Docmd.GoToControl "text351" 'This is the field that holds the value as a string to be held by Chartnam

Now up to here I am semi OK. I am able to open the right form but the cursor goes to the first entry and the form is not updated. Now if I tell the function to run again it goes to the right field and high lights the data I want. The problem is now how do I take the date and asign it to chartname to use it in the next statment which i

Docmd.OpenReport "SINGVISPT", acviewPreview, "", "", acnormal ' Open the report I want to nam
Docmd.OutputTo acReport, Chartname, "SnapshotFormat(*.snp)", "", False, "", 0 ' Name The report and save it as a snapshot

I hope now you can tell I am not that good in this but I really would like it to work I have thousands of these reports a day that I have to save all day long. Please help

I also have a link on the form where if I could open it I could automaticaly save the information in that link without having to type the address all the time

Thankyou in advanc
 
Musiwa,

As for setting the focus to text351, If you are doing this when the form
opens, I recommend moving this control to the top of the Tab Order.
Right-click the form in design view, and select Tab Order from the context
menu.

Now if you're saying that you want to open a report and save it as a
snapshot report (the name of which is specified in text351), then the
following code will do it:
DoCmd.OutputTo acOutputReport,"SINGVISPT", "Snapshot Format",
"c:\MyReports\" & text351 & ".snp", True

Is this what you're trying to do?

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

Musiwa said:
----- Graham R Seach wrote: -----

Musiwa,

The general syntax for referring to form controls is:
Forms!formname!controlname

So if you want to get teh value of a form control, you would do it like so:
Dim vMyValue As Variant 'Cause I don't know the datatype

vMyValue = Forms!frmMyForm!ctlMyControl

If you can be a bit more specific about how you want to pass this value on,
we might be able to offer a bit more help.

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

spanking
me. I am writting a code that opens a form named MYFORM. I do this with do
comand. I have a field in the form that I would like to read its value and
pass it to the save report command. The value of the field is used to name
the report. The field is unbound and is generated on the form but not stored
in a table. If you can show me how I can tell the user prior to asigning the
contents to the report name as to what the contants of the feild are I would
greately appreciate that too.

I appologise for the shabby information I gave. I do appreciate your
answer though. This is the code I have so far and a little explanation of
what I want to do.
Function SINGPTVsav ()
Dim ChartName as a string 'This variable holds the string that is read from the form
On Error go to SINGPTVsav_Err
Docmd.OpenForm "VisitPages",acNormal, "", "", , acNormal 'This
opens the form with the field I want
Docmd.GoToControl "text351" 'This is the field that holds the
value as a string to be held by Chartname
Now up to here I am semi OK. I am able to open the right form but the
cursor goes to the first entry and the form is not updated. Now if I tell
the function to run again it goes to the right field and high lights the
data I want. The problem is now how do I take the date and asign it to
chartname to use it in the next statment which is
Docmd.OpenReport "SINGVISPT", acviewPreview, "", "", acnormal ' Open the report I want to name
Docmd.OutputTo acReport, Chartname, "SnapshotFormat(*.snp)", "", False,
"", 0 ' Name The report and save it as a snapshot.
I hope now you can tell I am not that good in this but I really would like
it to work I have thousands of these reports a day that I have to save all
day long. Please help.
I also have a link on the form where if I could open it I could
automaticaly save the information in that link without having to type the
address all the time.
 
Back
Top