Results 1 to 5 of 5
  1. #1
    jbates is offline Novice
    Windows XP Access 2007
    Join Date
    Nov 2013
    Posts
    8

    Connecting Forms to a Report

    I have a report which is linked to a query. The report lists Names of Visitors,and dates of visits. I also have a form which I use to add/store the names of the visitors and their visit date. Visitors frequently re-visit the site, so therefore for each visit they do, I add as a new record, each with their own Primary ID number on the form.

    What I'm trying to achieve via a VBA code within the report is this, I wish to be able to click on the name of the visitor i.e. John Smith, which will then open/filter all of John Smiths forms. At the moment my report lists all of "John Smiths" visits by ID numbers, so I'm having to individually click on each ID to open up his record, my VBA code for that is:

    Private Sub ID_Click()
    On Error GoTo myError
    Dim varWhereClause As String
    varWhereClause = "ID = " & Me!ID
    DoCmd.OpenForm "frmVisitorScreen", , , varWhereClause
    leave:
    Exit Sub
    myError:
    MsgBox Error$
    Resume Next
    End Sub

    I'm wondering if I can use something similar. Help with this would be most appreciated.

    Thank you.

  2. #2
    burrina's Avatar
    burrina is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383
    You can create a query with the form name of the person in your query grid.
    HTH

  3. #3
    jbates is offline Novice
    Windows XP Access 2007
    Join Date
    Nov 2013
    Posts
    8
    Many thanks for your message. I was just wondering if you could elaborate on this. Sorry to be a pain, but Access is still a learning curb for me. I have a query based on the report, are you saying that I need to put some code in the 'Criteria'?

    Thanks again.

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

  5. #5
    jbates is offline Novice
    Windows XP Access 2007
    Join Date
    Nov 2013
    Posts
    8
    Thanks for the link, though it provided useful information it didn't help with what I was trying to set out to achieve. Basically I wanted to be able to click on one of many names of visitors i.e. "John Smith" from the report, which by clicking on his name will then open all of John Smiths records (which is taken from a form), whereby I can then edit their record(s). The report helps me to establish what records need updating, but the changes need to be done on their form.

    Anyway I managed to get the code to make this happen, it is as follows:

    Private Sub NameofVisitor_Click()
    Dim strWhere As String
    Dim DocName As String

    DocName = "Movement List"
    strWhere = "[NameofVisitor]='" & Me.NameofVisitor & "'"
    DoCmd.OpenForm "frmVisitorScreen", acNormal, , strWhere
    End Sub

    Thanks for your help.

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

Similar Threads

  1. Replies: 6
    Last Post: 07-18-2014, 11:35 AM
  2. Connecting three tables together
    By Lori944 in forum Access
    Replies: 3
    Last Post: 01-10-2014, 11:49 AM
  3. Connecting input masks to your forms
    By cmc14 in forum Forms
    Replies: 3
    Last Post: 04-25-2013, 02:40 PM
  4. mysql connecting help....
    By alex_raju in forum Access
    Replies: 1
    Last Post: 07-18-2011, 07:22 PM
  5. connecting many sub forms in one main form
    By Dasun in forum Programming
    Replies: 2
    Last Post: 07-01-2011, 02:39 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