Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create a report based on one criteria in form field 1

Status
Not open for further replies.

jsdavis

MIS
Apr 4, 2007
8
US
I have been looking up a ton of threads on this form trying to get exactly what I need but I still can't figure it out with what I've found. I'm sorry if this simple question has already been answered...

I have a report called CDIBReport which is fed from a query called CDIBQuery which contains data from two tables (Files & Members). I then have a main form with 3 subforms containing data from the two said files and another two (which are irrelevant for the report). When I pull up a record in the main and sub forms, some of them have information under the tab that contains the subform with member information (if they are a "member"). I want to be able to run the CDIBReport to create a report based on the "member_number" field in the Members_Subform. That means that I should have only one record showing up in the report as there is only one member number in the subform and every member number is unique.

I have a button on the Members_Subform which I want to click on to create the form. If, however, there isn't any data in the member_number field-there should be no report created (just a DoCmd.beep is what I want to put there if nothing should show up).

I've tried a ton of different code with this but haven't received many good results. I've had it to where I can print the report but it prints out all records in the query. Oh yeah, all of the tables are related by one Primary Key which is "FileID".

Here is the code I've been trying to work with:

Private Sub cmdEnrollmentCDIB_Click()

If Me.member_number.Value Is Null Then
DoCmd.Beep

Else
DoCmd.OpenReport "CDIBReport", acViewPreview, , FileID = Me.FileID, acWindowNormal
End If

End Sub

I'm not great at this coding thing yet so I might just be missing something but I would appreciate any help that anyone could give. Thank you!
 
you may try this:
DoCmd.OpenReport "CDIBReport", acViewPreview, , "FileID='" & Me!FileID & "'"

If FileID is defined as numeric then get rid of the single quotes.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
PHV,

That worked great. Thank you again for your help! You rock!

God Bless-
jsdavis
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top