Results 1 to 7 of 7
  1. #1
    dniezby is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Apr 2013
    Posts
    183

    Generate single record report based on field result?

    Okay, I need to generate a single record report based on a field's data.

    Here is my logic for what I need. I think I have the logic, I just don't know how to translate it. Any help would be greatly appreciated.

    User clicks a button to print the member's ID card.

    OnClick
    IF [membership_type] = 1


    open the report for BASIC MEMBER ID
    else
    [membership_type] = 2
    open the report for VIP MEMBER ID
    elseif
    messagebox = "No Membership Found"

    endif
    lastly, I have created the queries that generate the reports I want BUT it generates it for ALL my members that have type 1. How do I get it to work for JUST the current record I'm working with?

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,818
    Try something like:

    Dim strReport As String
    If Me.membership_type = 1 Then
    strReport = "BASIC"
    Else
    strReport = "VIP"
    End If
    DoCmd.OpenReport strReport, , , "[ID]=" & Me.ID

    Do you have separate tables for Basic and VIP members? Why not one table with another field for the member type?
    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
    dniezby is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Apr 2013
    Posts
    183
    Getting a runtime error 2580.

    Record Source does not exist.
    Code:
    Private Sub Command453_Click()
    Dim strReport As String
    If Me.mem_type = 1 Then
        strReport = "Basic_MemberID"
       
    ElseIf Me.mem_type = 2 Then
        strReport = "Platinum_MemberID"
    
    Else
        strReport = "General_MemberID"
        
    End If
    
    DoCmd.OpenReport strReport, , , "[ID_memtbl]=" & Me.ID_memtbl
    End Sub

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,818
    Don't know, never seen that error. Possibly more than one cause for such an error. Google it and see if anything fits. Step debug, link for guidelines at bottom of my post. Post db for analysis. Follow instructions at bottom of my post.
    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
    dniezby is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Apr 2013
    Posts
    183
    The debugger stops on this line

    Code:
    DoCmd.OpenReport strReport, , , "[ID_memtbl]=" & Me.ID_memtbl
    I found very little on this issue.

    This is the only one that seemed even close to my problem except I don't really understand it.
    http://www.vbforums.com/showthread.p...rce-At-RunTime

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,818
    And I got this one http://www.access-programmers.co.uk/....php?p=1242141

    Did you debug your code? Step debug, follow the code as it executes. It errors on what line? Does the variable get populated? Guidelines in link at bottom of my post.
    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
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,016
    Are you entering data for a new member, then clicking on this button? IF so, the problem may be that the Record hasn't been saved at this point, i.e. isn't really a Record. Try this line as the first line in your button code:

    If Me.Dirty Then Me.Dirty = False

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

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

Similar Threads

  1. Change field color based on result
    By dniezby in forum Programming
    Replies: 1
    Last Post: 05-01-2013, 09:43 PM
  2. Printing a single record in a report
    By kelann in forum Reports
    Replies: 28
    Last Post: 10-04-2012, 10:07 AM
  3. Replies: 7
    Last Post: 03-14-2012, 10:56 AM
  4. Replies: 9
    Last Post: 08-30-2011, 04:08 PM
  5. Query result based upon two field conditions
    By diane802 in forum Access
    Replies: 35
    Last Post: 01-08-2010, 06:31 PM

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