Transfer data from form to report - Please Help!!

S

Stockwell43

Hello,

I have a question about moving data.

I have an Access Form that has Unbound fields. I have a Report in access
that has every field from the form. When I type in the fields on the form and
then open the report, the report is blank. I do not want to save the
information to table. So how would I get this to work so when the user inputs
data in the form, it will show on the report when they click the preview
button?

Please simplify answer as I have not done anything like this before.

Thanks!!
 
A

andreas

Stockwell43 said:
Hello,

I have a question about moving data.

I have an Access Form that has Unbound fields. I have a Report in access
that has every field from the form. When I type in the fields on the form
and
then open the report, the report is blank. I do not want to save the
information to table. So how would I get this to work so when the user
inputs
data in the form, it will show on the report when they click the preview
button?

Please simplify answer as I have not done anything like this before.

Thanks!!
 
B

Beetle

The Form will need to be open - and remain open - when the Report is
opened and each control on the Report will need to have a reference to
the associated control on the Form (Forms an Reports have controls,
not fields). For example, each control on the report could have a
Control Source like;

=Forms!NameOfYourForm!NameOfControlOnForm
 
K

Ken Sheridan

For the ControlSource properties of the controls on the report reference
those on the form, e.g.

=[Forms]![MyForm]![MyTextBox]

Each control on the form will need to have been updated, i.e. by pressing
Enter, Tab or moving off the control with the mouse, so the best way to
ensure this is to open the report from a button on the same form with, e.g.

DoCmd.OpenReport "MyReport", View:=acViewPreview

The form will need to remain open when the report is opened, so if you want
it to close automatically then include code in the report's Close event
procedure to close the form, e.g.

DoCmd.Close acForm, "MyForm"

Another way, which allows you to close the form before the report opens,
would be to pass the values from the form to the report as its OpenArgs
property. For this you'd need either to parse the OpenArgs property to
extract the individual values, or a better way is to pass named arguments
using the module which I've posted at:


http://community.netscape.com/n/pfx...yMessages&tsn=1&tid=24091&webtag=ws-msdevapps


However you do it, one thing to watch out for is if you've used a combo box
on the form whose value is a hidden column, e.g. a combo box showing customer
names would usually have a numeric value of CustomerID in a hidden column.
In a case like this you could either use an identical combo box on the form,
which is inefficient, or include the customer name in a hidden text box on
the form with a ControlSource such as =[cboCustomer].[Column](1), which
references the second column of the combo box, the Column property being
zero-based. In the report you'd then reference the hidden text box rather
than the combo box.

Ken Sheridan
Stafford, England
 
S

Stockwell43

Thank you guys, I really appreciate the responses!!!!!! I will try this as
you made it quite simple to follow. Doesn't seem to bad but will try it and
see how I make out.

Thank you again and will let you know how it worked!

Ken Sheridan said:
For the ControlSource properties of the controls on the report reference
those on the form, e.g.

=[Forms]![MyForm]![MyTextBox]

Each control on the form will need to have been updated, i.e. by pressing
Enter, Tab or moving off the control with the mouse, so the best way to
ensure this is to open the report from a button on the same form with, e.g.

DoCmd.OpenReport "MyReport", View:=acViewPreview

The form will need to remain open when the report is opened, so if you want
it to close automatically then include code in the report's Close event
procedure to close the form, e.g.

DoCmd.Close acForm, "MyForm"

Another way, which allows you to close the form before the report opens,
would be to pass the values from the form to the report as its OpenArgs
property. For this you'd need either to parse the OpenArgs property to
extract the individual values, or a better way is to pass named arguments
using the module which I've posted at:


http://community.netscape.com/n/pfx...yMessages&tsn=1&tid=24091&webtag=ws-msdevapps


However you do it, one thing to watch out for is if you've used a combo box
on the form whose value is a hidden column, e.g. a combo box showing customer
names would usually have a numeric value of CustomerID in a hidden column.
In a case like this you could either use an identical combo box on the form,
which is inefficient, or include the customer name in a hidden text box on
the form with a ControlSource such as =[cboCustomer].[Column](1), which
references the second column of the combo box, the Column property being
zero-based. In the report you'd then reference the hidden text box rather
than the combo box.

Ken Sheridan
Stafford, England

Stockwell43 said:
Hello,

I have a question about moving data.

I have an Access Form that has Unbound fields. I have a Report in access
that has every field from the form. When I type in the fields on the form and
then open the report, the report is blank. I do not want to save the
information to table. So how would I get this to work so when the user inputs
data in the form, it will show on the report when they click the preview
button?

Please simplify answer as I have not done anything like this before.

Thanks!!
 
S

Stockwell43

I tested it on one field and it works perfect guys!!!!! Thank you so much for
your help and the easy to follow instructions. I saved it all in my notebook
for next time if I run into this again. I let you know if I run into any
issues along the way but it appears to be fine.

Have a great day!!!!!!!!

Ken Sheridan said:
For the ControlSource properties of the controls on the report reference
those on the form, e.g.

=[Forms]![MyForm]![MyTextBox]

Each control on the form will need to have been updated, i.e. by pressing
Enter, Tab or moving off the control with the mouse, so the best way to
ensure this is to open the report from a button on the same form with, e.g.

DoCmd.OpenReport "MyReport", View:=acViewPreview

The form will need to remain open when the report is opened, so if you want
it to close automatically then include code in the report's Close event
procedure to close the form, e.g.

DoCmd.Close acForm, "MyForm"

Another way, which allows you to close the form before the report opens,
would be to pass the values from the form to the report as its OpenArgs
property. For this you'd need either to parse the OpenArgs property to
extract the individual values, or a better way is to pass named arguments
using the module which I've posted at:


http://community.netscape.com/n/pfx...yMessages&tsn=1&tid=24091&webtag=ws-msdevapps


However you do it, one thing to watch out for is if you've used a combo box
on the form whose value is a hidden column, e.g. a combo box showing customer
names would usually have a numeric value of CustomerID in a hidden column.
In a case like this you could either use an identical combo box on the form,
which is inefficient, or include the customer name in a hidden text box on
the form with a ControlSource such as =[cboCustomer].[Column](1), which
references the second column of the combo box, the Column property being
zero-based. In the report you'd then reference the hidden text box rather
than the combo box.

Ken Sheridan
Stafford, England

Stockwell43 said:
Hello,

I have a question about moving data.

I have an Access Form that has Unbound fields. I have a Report in access
that has every field from the form. When I type in the fields on the form and
then open the report, the report is blank. I do not want to save the
information to table. So how would I get this to work so when the user inputs
data in the form, it will show on the report when they click the preview
button?

Please simplify answer as I have not done anything like this before.

Thanks!!
 
L

Larry Linson

Stockwell43 said:
I tested it on one field and it works perfect guys!
Thank you so much for your help and the easy to
follow instructions. I saved it all in my notebook
for next time if I run into this again. I let you know
if I run into any issues along the way but it
appears to be fine.

Access Reports are intended to be bound to a Table or Query as Record
Source. As you see, you can "work around" this, but in the long run, it's
easier, quicker, and you eliminate some of "life's little surprises" if you
learn and follow "The Access Way". It might have been as easy, or easier,
to create a table just for the purpose, explicitly save the Form data, and
open the Report with a DoCmd.OpenReport.

If your Table is a single-record Table, you wouldn't have any great problem
with accumulating unneede data... you'd just overwrite the existing record,
and unless it was a very large one, you wouldn't even increase the frequency
with which you need to Compact and Repair very much.

Larry Linson
Microsoft Office Access MVP
 
S

Stockwell43

Hi Larry,

I realize the reports are bound to a table or query, I was trying to avoid
saving the information to a table. Now you mention a "Single Record Table" So
essentially it doesn't save any data? So as a user fills out forms, clicks on
the report to preview and print it will automatically overwrite the previous
on it's own? Sorry for sounding dense, I never did that before. Could you
please give me a little more detail?

Thanks!!
 
L

Larry Linson

Create a table with a "unique ID", and whenever you save to the table, use
the same "unique ID" (for example, a numeric value of 1. That way, the
current record saves as the only record. The space occupied by the original
record may be lost until the next Compact operation, but with data manually
typed, isn't going to eat away at your disk capacity.

I was not suggesting that _instead_ of what had been suggested, however -- I
don't know that it would be any easier or more efficient. I was simply
mentioning it as an alternative, and an "incentive" for becoming familiar
with "The Access Way" and working with Access rather than having to "work
around" Access.

Larry Linson
Microsoft Office Access MVP
 
S

Stockwell43

I appreciate the idea, always willing to learn more. I have saved your
information in my access code folder. I will try this as a test to see how it
works. Thank you for the explanation and help and appreciate the input!
 

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