Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2009

    Unanswered: Open form from a subform to specific record

    I am new to this program and need help to design a small database. I am making a dataset to track people’s visits to our office - so I have made 2 tables. The first is the demographic table with each person’s SSN being the primary key. The second table is a visit level data where SSN and Visit_date are the primary keys. When I open the database – I have it set up to open a form with a subform – the form is the demographic level data and the subform is the bare basics from the visit level data. I want to make it so that we can click on either a button beside each visit date or the visit_date field to open the visit form on that specific record. Does this make sense? I am having trouble with the visual basic code because I don’t know how to handle the demographic table not having the visit_date. I can get a command button to work to open the form but it goes to the first record in that table which doesn’t help me. Any suggestions would be great!


  2. #2
    Join Date
    May 2005
    Welcome to the forums

    Quote Originally Posted by sammarai
    The first is the demographic table with each person’s SSN being the primary key.
    I would STRONGLY discourage you from using a SSN as anything but a confidential record for HR only! There are so many legal risks involved there, it's best to ONLY use the SSN when you're absolutely sure (1) that you HAVE to use it, and (2) you can be sure to keep it secure.

    But back to your question. When you open the form you can either simply filter only the record you want using the third argument of the OpenForm Method, or you can use the generic OpenArgs argument in conjunction with the FindRecord method, but I'm not sure how good your VB skills are and that method takes a bit more work.
    Me.Geek = True

  3. #3
    Join Date
    Apr 2009
    I have to use SSN because of how the data is set up in the original dataset. This is a very secure server - you have to have a card and logon id/password to get access.

    Anyway back to the question - I have tried the doCMD.openform but I keep getting errors. This is the code that I am using...

    private sub opnrds_click()
    DoCmd.OpenForm "rds", , , "[SSN]='" & Me!SSN & "' AND [visit_date]=#" & Me!visit_date & "#"
    end sub

    I know I am doing this wrong but I don't know what to do. I have NO IDEA what I am doing if it isn't obvious to you already

  4. #4
    Join Date
    Nov 2007
    Adelaide, South Australia
    I have tried the doCMD.openform but I keep getting errors
    The code looks ok. What errors are you getting?
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!

    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts