Results 1 to 12 of 12
  1. #1
    burrina's Avatar
    burrina is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383

    Popup Form Show Related Data From Main Form.

    I have the fields needed on my main form but there is no room for them. So I have a popup form that shows the history of the record.
    I need the popup form to show ONLY the data related to that specific record. 2 fields are a checkbox and a date field.
    Here is my code now that opens the popup form. The Primary Key is EventID What happens is that the popup shows all the PK's no matter what. Popup recordsource is the same table as main form.Popup is also a continuous form. I want to be able and see all the entries for that record ONLY. EventID is what should tie them together!

    On Error GoTo Err_history_Click

    Dim stDocName As String


    Dim stLinkCriteria As String

    stDocName = "frmEventSubTwo"
    DoCmd.OpenForm stDocName, , , stLinkCriteria
    strCriteria = "[EventID] = " & Me![EventID]

    Exit_history_Click:
    Exit Sub

    Err_history_Click:
    MsgBox Err.Description
    Resume Exit_history_Click

  2. #2
    ketbdnetbp is offline Competent Performer
    Windows 7 32bit Access 2003
    Join Date
    Mar 2011
    Location
    Midwest
    Posts
    254
    Burrina -

    Not sure if this is the problem but, you have...

    On Error GoTo Err_history_Click
    Dim stDocName As String
    Dim stLinkCriteria As String
    stDocName = "frmEventSubTwo"
    DoCmd.OpenForm stDocName, , , stLinkCriteria
    strCriteria = "[EventID] = " & Me![EventID]
    Exit_history_Click:
    Exit Sub
    Err_history_Click:
    MsgBox Err.Description
    Resume Exit_history_Click

    You made need to change this line (add red text):

    strLinkCriteria = "[EventID] = " & Me![EventID] 'Assumes [EventID] is numerical

    as there was a typo "link" was missing and this controls the filtering.

    All the best,

    Jim

  3. #3
    burrina's Avatar
    burrina is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383
    Good catch, I corrected that but no difference! YES, EventID is a number, it is the Primary Key.

  4. #4
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    You have to have the strLinkCriteria line BEFORE the DoCmd.OpenForm line!!!

    You have
    Code:
    On Error GoTo Err_history_Click
    
        Dim stDocName As String
        Dim stLinkCriteria As String
    
        stDocName = "frmEventSubTwo"
        DoCmd.OpenForm stDocName, , , stLinkCriteria
        strCriteria = "[EventID] = " & Me![EventID]
    
    Exit_history_Click:
        Exit Sub
    
    Err_history_Click:
        MsgBox Err.Description
        Resume Exit_history_Click
    "stLinkCriteria" is empty when the open form command is executed.



    It should be:
    Code:
    On Error GoTo Err_history_Click
    
        Dim stDocName As String
        Dim stLinkCriteria As String
    
        stLinkCriteria= "[EventID] = " & Me![EventID]  'added "Link"as per ketbdnetbp :)
        stDocName = "frmEventSubTwo"
        DoCmd.OpenForm stDocName, , , stLinkCriteria
    
    
    Exit_history_Click:
        Exit Sub
    
    Err_history_Click:
        MsgBox Err.Description
        Resume Exit_history_Click

  5. #5
    burrina's Avatar
    burrina is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383

    Here is a screenshot of the results

    Hmmm, adjusted that and still same result.
    Attached Thumbnails Attached Thumbnails InActionResults.jpg  

  6. #6
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    So the next step is to check if the event ID is correct. Add the BLUE line
    Code:
        stLinkCriteria= "[EventID] = " & Me![EventID] 
        Msgbox stLinkCriteria
        stDocName = "frmEventSubTwo"
        DoCmd.OpenForm stDocName, , , stLinkCriteria

    Next, does the form "frmEventSubTwo" have the field "[EventID]" in the record source?

  7. #7
    burrina's Avatar
    burrina is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383
    messagebox showed nothing.

  8. #8
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    There you go..... So why is Me![EventID] NULL???


    Try changing the line to:
    Code:
        DoCmd.OpenForm stDocName, , , "[EventID] = 21"
    Are the correct records returned??

  9. #9
    burrina's Avatar
    burrina is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383
    That would work of course but when I need to see other records??? I don't know why it is null! I need a " " filter or something so it can use whatever value the record is on.i.e. EventID Maybe EventID.Value I have not tried that yet!

  10. #10
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    "Value" is the default property so adding ".Value" won't gain anything.

    In your attachment, you show a control with a value of 21. You have to figure out why Me.EventID is returning a NULL. When you call the code, are you on the same form as the event id control. Is the event ID control on a subform?

  11. #11
    burrina's Avatar
    burrina is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383
    SOLUTION: Base the popup form on a query and use this as the criteria for EventID

    =[Forms]![frmEvent]![EventID]

    Thanks for your help.

  12. #12
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    I base all forms on queries. Easier to filter/sort.....

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

Similar Threads

  1. Popup form refreshes main form?
    By kawi6rr in forum Programming
    Replies: 2
    Last Post: 08-04-2012, 09:17 AM
  2. Replies: 1
    Last Post: 02-29-2012, 09:38 AM
  3. copy from popup form to main form
    By alex_raju in forum Forms
    Replies: 2
    Last Post: 02-10-2012, 05:29 PM
  4. Updating Main form from a popup form
    By wdrspens in forum Forms
    Replies: 21
    Last Post: 06-13-2011, 01:34 AM
  5. Show related data on a form
    By Accessgrasshopper in forum Forms
    Replies: 4
    Last Post: 03-17-2011, 07:53 PM

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