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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need code make something invisible on report

Status
Not open for further replies.

doerfohio

Technical User
Aug 30, 2004
34
US
On my RegForClassSignIn form, the startdate, enddate, controls all have a date in them. Our related table requires it. This is fine because we never want those left blank. But now we have a situation where we don't want the date to show up on the ReceiptSignIn report (which shows up when Registercmd is clicked). So I want to add code to the Registercmd's "subprint receipt" that says something this:

If RegForClassSignIn (form where Register cmd resides).lstprogram = membership
Then ReceiptSignIn (that's the report) fields: startdate and enddate.visible = false
End if

But I don't know the language.

And I don't know where to put it in the print receipt sub.

Here's what's already there:
Code:
Public Sub subPrintReceipt()
Dim response As Integer
Dim stDocName As String
    Dim qdfTemp As QueryDef
    Set db = CurrentDb
'----------------------------------------------
'   Print Receipt
'----------------------------------------------
response = MsgBox("Registration Complete... Want to print Receipt?", vbYesNo)
If response = 6 Then ' yes
DoCmd.DeleteObject acQuery, "qryreceipt"
'Set qdfTemp = db.CreateQueryDef("qryReceipt", _
'"SELECT Members.LastName, Members.FirstName, Members.Address, Members.City, Members.State, Members.Zip, Members.Birthdate, MemClasses.ClassID, MemClasses.ClassDesc, memclasses.SubDesc, MemClasses.MemberID, MemClasses.CategoryID, MemClasses.StartDate, MemClasses.EndDate, MemClasses.LocID, MemClasses.Maximum, MemClasses.CurEnrollment, MemClasses.DatePaid, MemClasses.MemFee, MemClasses.PgmFee, MemClasses.TeamFee, MemClasses.Amount, MemClasses.Checknum, MemClasses.Cash, MemClasses.mon, MemClasses.tue, MemClasses.wed, MemClasses.thu, MemClasses.fri, MemClasses.sat, MemClasses.sun, MemClasses.Cash, MemClasses.CCamt, MemClasses.Ckamt, MemClasses.Certamt, MemClasses.Slipamt, MemClasses.Cashamt, MemClasses.CSlip, MemClasses.GiftCert, MemClasses.CCard, MemClasses.Cash, MemClasses.Check, MemClasses.Waiver, MemClasses.StartDate, MemClasses.EndDate, MemClasses.MemNotes FROM Members INNER JOIN MemClasses ON Members.MemberID = MemClasses.MemberID " & _
'"WHERE MemClasses.DatePaid=[forms]![regforclasssignin]![txtdatepaid] OR MemClasses.ClassID=[forms]![regforclasssignin]![classid] AND MemClasses.MemberID=[forms]![regforclasssignin]![memberid]")
Set qdfTemp = db.CreateQueryDef("qryReceipt", _
"SELECT initials.initials, Members.LastName, Members.FirstName, Members.Address, Members.City, Members.State, Members.Zip, Members.Birthdate, MemClasses.ClassID, MemClasses.ClassDesc, memclasses.SubDesc, MemClasses.MemberID, MemClasses.CategoryID, MemClasses.StartDate, MemClasses.EndDate, MemClasses.LocID, MemClasses.Maximum, MemClasses.CurEnrollment, MemClasses.DatePaid, MemClasses.MemFee, MemClasses.PgmFee, MemClasses.TeamFee, MemClasses.Amount, MemClasses.Checknum, MemClasses.Cash, MemClasses.mon, MemClasses.tue, MemClasses.wed, MemClasses.thu, MemClasses.fri, MemClasses.sat, MemClasses.sun, MemClasses.Cash, MemClasses.CCamt, MemClasses.Ckamt, MemClasses.Certamt, MemClasses.Slipamt, MemClasses.Cashamt, MemClasses.CSlip, MemClasses.GiftCert, MemClasses.CCard, MemClasses.Cash, MemClasses.Check, MemClasses.Waiver, MemClasses.StartDate, memclasses.monthly, MemClasses.EndDate, MemClasses.MemNotes " & _
"FROM (Members INNER JOIN MemClasses ON Members.MemberID = MemClasses.MemberID) LEFT JOIN Initials ON MemClasses.IDinitials = Initials.IDinitials " & _
"WHERE MemClasses.DatePaid=[forms]![regforclasssignin]![txtdatepaid] OR MemClasses.ClassID=[forms]![regforclasssignin]![classid] AND MemClasses.MemberID=[forms]![regforclasssignin]![memberid]")
   'FROM (Members INNER JOIN MemClasses ON Members.MemberID = MemClasses.MemberID) LEFT JOIN Initials ON MemClasses.IDinitials = Initials.IDinitials
    
    DoCmd.OpenReport "receiptSignin", acPreview, , _
    "[memberid] = forms![RegForClassSignin]!txtid and [datepaid] = forms![regforclasssignin]!txtdatepaid"
End If
End Sub

Thanks for your help!

~Dori
 
You need to add code to the report, not to the form.
In the report, you can reference the form:
Code:
if not isloaded("RegForClassSignIn") then 
   ' skip this part
else
   if Forms!RegForClassSignIn.lstprogram.value = [COLOR=blue]yourcriteria[/color] then
      me.startdate.visible = false
      me.enddate.visible = false
   end if
end if

Greg
"Personally, I am always ready to learn, although I do not always like being taught." - Winston Churchill
 
Do I add this to the Open Event of the report?
 
Try it there. If that is a problem, try it in the format event of the detail section, if that's where the dates are.
 
I got an error on the IsLoaded part: Compile error: "sub or function not defined"

Otherwise it works! But I really need that part because occasionally we have to run that report without the RegForClassSignIn form open. On those rare occasions, it will have nothing to do with the membership category, so I don't have to worry about it showing the dates.

Thanks,
Dori
 
How are ya doerfohio . . .
doerfohio said:
[blue] . . . we have a situation where we don't want the date to show up on the ReceiptSignIn report . . .[/blue]
Include the dates in the [blue]RecordSource[/blue] of the form for manipulation/filtering/ect . . . just [blue]don't physically put them on the report! . . .[/blue]

[blue]Your Thoughts? . . .[/blue]

Calvin.gif
See Ya! . . . . . .
 
But we need the dates on the report. The report is a receipt we give to our members when they sign up for a class. And they need to see when the class starts and ends. Now we are adding "membership" to our class list. We don't want to show dates on membership receipts because there are so many different membership time lengths--1 week, 2 weeks, semester, summer, Christmas break, 1 year, and many more.
 
Try
Code:
If CurrentProject.AllForms("RegForClassSignIn").IsLoaded = True Then
I took earlier example from Microsoft website - this one is from a working database.



Greg
"Personally, I am always ready to learn, although I do not always like being taught." - Winston Churchill
 
Ummm.. oddly enough, any field on a report has a VISIBLE property..I'd suppose that setting it to NO for your unwanted dates might do the trick ???






"For a successful technology, reality must take precedence over public relations, for Nature cannot be fooled." - Richard P. Feynman
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top