Newbie wanting Form Help

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

Guest

I have a Form that collects simple data from a medical chart review. It is set up to always enter new data when opened and the data is placed into a table. The table is linked to 2 other tables that contain Resident names and Faculty names.

I have placed a Command Button at the bottom so that when you finish entering the data on the form..you can print out that record...but I would prefer to have the button create an event where all the data just entered is sent to a more formal report for printing. I know i can set the button to print a report...but how do I get it to print a "report" that uses only the record that was just entered instead of a bunch of records.

eg...Data entered to Form (review)---which is added as a new record to Table (review)---command button sends the newly entered record of data to be printed as a report that has a nicer printed format than the bland data entry form..

Thanks for any help...
 
Ron,
Try the following:

Create your report bound to your table.

You need to find a unique field in your table. The primary key would do nicely.
If the field you have chosen is not already on your form, create a textbox and bind
the field to it. Set the text boxes visibility property to no if you do not want it shown
on the form. If the field is there already, skip the above.

In your Command buttons On Click property type:

Private Sub cmdOpenReport_Click()
Dim strWhere

strWhere= txtUniqueField.Value
DoCmd.OpenReport "Report_Name", acViewNormal, , strWhere

End Sub

Change the names of your report and fields to correspond to your database.

Hope this helps
Rosco
 
Ron,
Try the following:
Create your report bound to your table.

You need to find a unique field in your table. The primary key would do nicely.
If the field you have chosen is not already on your form, create a textbox and bind
the field to it. Set the text boxes visibility property to no if you do not want it shown
on the form.

In your Command buttons On Click property type:

Private Sub cmdOpenReport_Click()
Dim Variable_Name

Variable_Name= txtUniqueField.Value
DoCmd.OpenReport "Report_Name", acViewNormal, , Where

End Sub

When you declare the variable "Variable_Name", you should declare it as a type ( string, integer, etc) depending on what info is stored in the filed.
Change the names of your report and fields to correspond to your database.

Hope this helps
Rosco
 
Thanks...My first attempt netted the same report of all records, not the one just entered..so I will try it again

If my Uniqe Field on the Form is ID (Auto Number)..would it look like this?

Private Sub cmdOpenReport_Click()
Dim Variable_Name as Integer

Variable_Name= ID.Value
DoCmd.OpenReport "Report_Name", acViewNormal, , Variable_Name

End Sub


Thanks..
 
I found this code that worked....couldn't get yours to work..

Private Sub Command24_Click()
Dim strCriteria As String



' This works when your matching field is a number
strCriteria = "[ID] = " & Me!ID
DoCmd.OpenReport "TestPrintReport", acPreview, , strCriteria

End Sub
 
Back
Top