lazyj said:
Yes, I have created several reports and as you say, they show all the
records
in the database. And thank you for taking the time. It is most
appreciated.
Great!
Ok, we done step #1, now lets do step two (by the way, my apologies, looking
at the original text of step #2, it is a mess (I am using voice dictation
software --- it often munges things...).
Ok, now, lets do step #2. Step #2 is:
2) set things so that when the report is launched, it will show ONLY the
current reocrd we are
viewing in the form.
This step is more difficult because we are going to place a button
on your form. I'm going to suggest
that you do not use the wizards here. So,
we now need to open up your form in design mode. You then need to select a
button from the toolbox and place it on your form. You should also consider
disabling or turning off the wizards just for this one task, and then turn
the wizards back on when done.
You now want to right click on that button on the form in design mode and
then
select build event.
At this point in time you should get three options:
Macro Builder
Expression Builder
Code Builder
We want to choose the 3rd option.
I also have a series of screen shots here that shows you how to place a
button on a form and then bring up the event designer. You can find a series
of screen shots here:
http://www.members.shaw.ca/AlbertKallal/wordmerge/Details.htm
please scroll down to the following part in the above article:
"Adding the command button to your Form"
Notice on the above instructions I also mention how to turn off the wizards.
So either of the above the two approaches should work for you. Once again
I'm not sure of your skill level and I not sure where I lost you in my
original post. However at this point we are going to place a buttion on the
form (when in design mode). When you finally get into the code editor as
shown in those screen shots, then we're ready to type in some programming
code behind that button. The code that's going to be placed behind this
button on the form is going to be as follows:
dim strReport as string
strReport = "Name of you cool report goes here"
me.refresh
docmd.OpenReport strReport,acViewPreview,,"id = " & me!id
The above code will have to be modifed to your needs. Lets take this step by
step:
strReport = "Name of you cool report goes here"
In the above line of code, you're going to have to replace the text "name of
your cool... with the actual name of the report you created. Once again I
can't read your mind! So, you'll have to modify the above line of code to
reflect the actual name of the report that you used.
The next line of code does not need to be changed:
me.Refresh
The above line of code simply forces the current forms data to be written to
disk (the table). We need to do this so that when we launch a report it
shows the latest updated data. Keep in mind the report pulls the data from
the actual table, not from your form. so unless we force the forms data to
be saved, the report will not reflect any changes you've just made to the
form.
Ok, the next line of code that will have to be modified to work on your
system is:
docmd.OpenReport strReport,acViewPreview,,"id = " & me!id
In the above you're going to have to replace "id" with the actual name of
the unique identifier for each record in your table. This unique identifier
is typically Referred to as a primary key in database lingo terms. So for
example if your primary key in your table was contactID, then you'd replace
the above line of code with:
docmd.OpenReport strReport,acViewPreview,,"Contactid = " & me!Contactid
OK once you've modifed the above lines of code, you can now close the form
and save it. If you open the form in view mode, you should be able to press
this button you've just added and it should launch a report with only the
ONE record that you're viewing. At this point you could even test printing
out the report to the printer. Now, close the report, and try moving to a
few different records and pressing this button and see if it launches a
report to the one record you are viewing.
So the above is step number two, and we have to get this part working before
we can advance the next step number three in which we attempt to e-mail the
report.
So let's get the above working, once you get the above process up and
running, then we can move forward again.
--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
(e-mail address removed)
as I mentioned since you're unable to follow my original structure as it's
hard to tell how far we can get along in this process
, and then get into the code builder
As mentioned it somewhat difficult to know the skil level of your abilities
here. Im not really sure at what point in mto my original structure is that
what you got lost, , since you could not follow my original and structure as
I'm not sure if you've ever designed are built forms and design mode, I
thought the structure quite clear and simple, but
so from that
to that
report