Access 2002 form/report issues

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Stewie0920

Thread Starter
Joined
Sep 10, 2008
Messages
12
I was looking for help with a db I created in Access 2002. I have users that need to enter information in a form and there are many fields. Some of which are required. which the form works great. But the problem I am having is that I want the user to be able to print a report that corresponds with what is on the form but only if the forms mandatory fields are filled in. Right now I have a command button on the bottom of the form that opens the report in print preview status but you can click on it at any time. I don't want to give the users the opportunity to not have to fill in all the required fields.

Any help with this would be greatly appreciated. I haven't programmed in a long time (10 years) I never took a VB class either.

Thanks
 

OBP

Joined
Mar 8, 2005
Messages
19,895
You can add some VBA code to the Button that opens the report that checks the values of the mandatory fields and if they are null exit before Print Preview.
The code is like this
if isnull(me.fieldname1) or isnull(me.fieldname2) then Exit Sub
or better still
if isnull(me.fieldname1) or isnull(me.fieldname2) then
Msgbox "Please fill in all the required data before Printing"
Exit Sub
end if

When you go in to the VBA Editor and type in
me.
which means the Open form that you are in, the VBA Editor will present you with a list of all of the Controls and Action Options on the Form so that you can choose your Field names where I have Fieldname1 and fieldname2 etc.

Have you coloured the Background of the mandatory fields so the users know which ones they are?
 

Stewie0920

Thread Starter
Joined
Sep 10, 2008
Messages
12
its been a while since I used if statements, it was interesting. But I did get it working so that you cannot press the button without all mandatory fields filled in. Now I get to figure out why my data that i entered in the form does not show up on the report. as for the color I will work that in somewhere possibly.
Thanks for your help
 

Stewie0920

Thread Starter
Joined
Sep 10, 2008
Messages
12
I now have data on the report but it is data that was from a previous entry. I want to print the current form data that I am on. also the form comes up blank which is what I want also. (data entry form) Can you help?

Thanks
Stewie0920
 

Stewie0920

Thread Starter
Joined
Sep 10, 2008
Messages
12
No I do not run a query. Should I? I guess I was under the assumption that I can bring up the report from the current form that I am on.
 

OBP

Joined
Mar 8, 2005
Messages
19,895
You can bring it up from the current Form, but if you want it to show data relating to the current record you either have to use the "Filter" option in Open Form part of the VBA of the Command Button, or you can create a query to supply the report with data and you can have lot's of Filters using the Criteria Row of the Query. This is very useful for "Searching" as well as reports.
You enter in to the Criteria Row for the Query Column that you want to control
forms![form name]![field name]
where form name is the actual name of your form and field name is the actual name of the field on the form.
So if you want the same record as the one that you are you could use
forms![form name]![ID field name]
in the ID Field name column of the Query.
 

Stewie0920

Thread Starter
Joined
Sep 10, 2008
Messages
12
I guess I am really confused. I created the form to enter data into the database. (which I don't even want to save the data) From the form I want to give the user 2 options. Print the data that they just typed in, in a report format to a printer at one of our other locations or email the data in a report format to someone at another location.

Actually I have 7 different forms that I need to create and based on those forms the same exact thing will need to happen.
Print the data that they just typed in, in a report format to a printer at one of our other locations or email the data in a report format to someone at another location or they can do both.

I also want to put a close form button on the bottom of the form and have the user click on it to go back to the switchboard.

Boy do I need to take a class
Thanks Stewie
 

OBP

Joined
Mar 8, 2005
Messages
19,895
If you don't want to save the data wouldn't you be better off using Word with Templates?
Or are you using Access to supply some choices?
 

Stewie0920

Thread Starter
Joined
Sep 10, 2008
Messages
12
After I get the main stuff setup and working I want to incorporate specific fields that the user can pick what product the patient is going to get and also what doctor the patient uses so I figured if I was going to do that I would need to create tables with doctors names and addresses and also a product table with corresponding codes that get filled in when a product is chosen.
 

OBP

Joined
Mar 8, 2005
Messages
19,895
Then Access is right for the job.
If you need more help post a zipped copy of the database and I will look at it for you.
 

OBP

Joined
Mar 8, 2005
Messages
19,895
Before zipping the database you should use the Access main menu>Tools>Database Utilities>Compact & Repair Database to Compact your database, that should make it smaller. After you have zipped it you use the Buttons "Go Advanced" and then "Manage Attachments" which are under where you type in your Replies.
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Members online

Top