Results 1 to 7 of 7
  1. #1
    86rainey is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2012
    Posts
    3

    Opening a form for a particular record.

    Hi everyone.

    I'm new to access so please bear with me!

    I have a Database to store people's names and payments they have made. I have a table to store information about each. One person can have many payments and I've created such a relationship. I have a form that displays certain groups of people. I would like to have a command button beside each name that would open a form with their relevent payment records. I can get the payments form open but not the matching record. Any idea how to do this?



    Any help or guidance would be great!

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Show the code you use to open the form. Is it a macro or VBA? Are you using DoCmd.OpenForm? Use the WHERE CONDITION argument of th OpenForm method, something like: "ClientID=" & Me.ClientID
    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
    86rainey is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2012
    Posts
    3
    This is the code I'm using:

    DoCmd.OpenForm "Inv_Payments", , , "SQA_Number = " & Me.SQA_Number

    Clicking the button gives me an InputBox, looking for the SQA_Number. I want it to take the current SQA number and open the matching record from another table.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Is SQA_Number a number or text field? If text, need apostrophe delimiters:

    "SQA_Number = '" & Me.SQA_Number & "'"

    I don't understand why you are getting an input prompt. That indicates to me a query input parameter. If VBA could not find Me.SQA_Number, should trigger an error message, not an input prompt.
    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
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Quote Originally Posted by June7 View Post
    ...I don't understand why you are getting an input prompt. That indicates to me a query input parameter. If VBA could not find Me.SQA_Number, should trigger an error message, not an input prompt.
    I used to think that, too, but in actuality, Access will do this if SQA_Number doesn't exist on the Form named Inv_Payments!

    It may simply not exist or it could be spelled differently on the Form being opened.

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

    All posts/responses based on Access 2003/2007

  6. #6
    86rainey is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2012
    Posts
    3
    SQA_Number is a field on the first form, Class_List, and is also present on the second, Inv_Payments. Both forms are tables, SQA_Number is the primary key in Class_List and the foreign key in Inv_Payments.

    The data type for SQA_Number is number. I added in a MSGBOX to tell me what value is stored in SQA_Number when I press the command button. The number matches the current record in form 1 (Class_List), but the second form (Inv_Payments) still opens at record 1.

  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,018
    Quote Originally Posted by 86rainey View Post
    SQA_Number is a field on the first form, Class_List, and is also present on the second, Inv_Payments. Both forms are tables, SQA_Number is the primary key in Class_List and the foreign key in Inv_Payments.
    A couple of things:

    Both forms are tables makes no sense! Forms aren't Tables! Perhaps you meant that both Forms were directly based on Tables?

    Also, vis a vis SQA_Number is the primary key in Class_List and the foreign key in Inv_Payments; Forms do not have Primary Keys or Foreign Keys, Tables do! This is not just being picky about terminology, you need to have at least a basic understanding of these things to do this kind of work.

    That said, something is simply not right, here! Are you sure that
    SQA_Number is on the Inv_Payments Form, as opposed to simply being in the Table?

    I see no way we can help you further unless you can Zip up your file and attach it to a post so that we can look at it. The instructions for doing this are at the bottom of June7's post.

    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. opening a form with last one record.
    By cap.zadi in forum Forms
    Replies: 1
    Last Post: 01-17-2012, 12:45 AM
  2. Replies: 9
    Last Post: 09-16-2011, 03:52 PM
  3. Form Not Opening Correct Record
    By halfaguava in forum Forms
    Replies: 1
    Last Post: 06-09-2011, 07:00 PM
  4. Replies: 1
    Last Post: 11-09-2010, 03:02 PM
  5. Opening a form at a blank record
    By Remster in forum Forms
    Replies: 2
    Last Post: 09-14-2010, 07:46 AM

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