Results 1 to 8 of 8
  1. #1
    rhewitt is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2012
    Posts
    74

    Generate button in report ONLY IF link exists


    I have a report that includes buttons that link to external websites. Each button dynamically generates the URL by concatenating a base URL with a UID (from table), which opens the appropriate webpage (Species profile). The more rare / recently discovered a species is, the less likely that there's a species profile.

    Rather than showing a button for EVERY species (as some will open a 'Species has no profile' generic webpage), I'd like to only show buttons where a full URL exists.

    I'm assuming this would have to be tied to something like an OnLoad event for the report.

    The following only works on the first record. If that's Null, it doesn't create any buttons. If the first value is notNull, it creates a button for every record. Seems like I need to loop through all records with this test, but I'm not sure how to accomplish this.
    Code:
    Private Sub Report_Load()
        If IsNull(Me.ECOScode) Then
            Me.ECOSbutton.Visible = False
        Else
            Me.ECOSbutton.Visible = True   
    End Sub
    Click image for larger version. 

Name:	Report.png 
Views:	10 
Size:	47.1 KB 
ID:	9711

    Thanks for any help you can offer,
    Roy
    Last edited by rhewitt; 10-25-2012 at 12:29 PM.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,603
    I tried some code just recently to set properties of controls on a report. Didn't work and I gave up. The event I used was OnFormat for Detail section.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    rhewitt is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2012
    Posts
    74
    The Format even looks promising... can't seem to get the output the ECOScode value of the current record with Debug.Print.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,603
    The issue is there is only one control involved, as can be seen in design view. The control is repeated for each record displayed but it is only one control. Setting property by code sets it for all instances of the control on the report. At least that was my experience for the properties I was trying to code. Maybe Visible property will be different.

    Try your code in the OnFormat event. Don't forget the End If which is missing from your first posted code. No 'Loop', the Format event should be applied to each record.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    rhewitt is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2012
    Posts
    74
    WOW! Apparently this event isn't fired in ReportView, only in Print View! That doesn't make a lick of sense.

    http://database.ittoolbox.com/groups...report-4756326

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,603
    Sorry, I should have thought to mention that. Format event fires only for PrintPreview or direct to printer.

    So this issue resolved?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    rhewitt is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2012
    Posts
    74
    Solved in the sense that it doesn't have a solution. Why would Microsoft make events that fire only in certain views. That's something I may never understand.

    Thanks again for your help,
    Roy

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,603
    Of yeah - can't click on button in PrintPreview. Nasty Catch22!
    Last edited by June7; 10-25-2012 at 05:28 PM.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. how to generate this simple report in report ms access
    By learning_graccess in forum Reports
    Replies: 1
    Last Post: 11-26-2011, 02:10 PM
  2. Get combo box value to generate report
    By chuyee17 in forum Access
    Replies: 3
    Last Post: 10-28-2011, 05:24 AM
  3. Replies: 2
    Last Post: 06-09-2011, 09:47 AM
  4. Link Excel file to MS Access and generate rep
    By Priceless in forum Import/Export Data
    Replies: 14
    Last Post: 02-21-2011, 02:08 PM
  5. Pdf Report Generate from Access
    By ACHU in forum Reports
    Replies: 1
    Last Post: 10-29-2009, 07:49 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums