Page 1 of 2 12 LastLast
Results 1 to 15 of 20
  1. #1
    pfales is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2013
    Posts
    23

    Question Selecting a record from a sub form

    Hello,


    I am not surehow to properly ask this question but I will try my best. I have a form in which I have included a sub form (frmActivity_List and sfmActivity_List respectively), the sub-form is a list box that will show the specific User (unless they are an admin) only their entries into the database/table. What I would like to do is be able to have the User double click a record and have the selected record entry open for editing by the user. The script I am using is;
    Code:
     Private Sub Form_DblClick(Cancel As Integer)
    DoCmd.Close acForm, "frmActivity_List", acSaveYes
    'DoCmd.OpenForm "frmDaily", acNormal, , "DID = " & Me.DID, , , MCreatedBy
    DoCmd.OpenForm "frmDaily", , , "DID=" & Me.DID, , , txtUserID
    End Sub
    I have this script in both the frmActivity_List and sfmActivity_List code windows (hope I said that correctly). The code in a way kind of works because it will open the parent form for editing however it only only picks up the first form in the list box and not the record I have selected. What I mean is lets say there are five records showing in the list box and I select the fourth record in the list. The code runswithout error (amazingly) however when the record opens it is the first record in the list and not the one I selected.

    How can I correct this so that the record that is selected is the one that opens?

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    Here's an example of using a listbox on a subform

    pfales.zip

  3. #3
    pfales is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2013
    Posts
    23
    rpeare,

    Thank you for the example that you provided. Thank fully the sub-form populates exactly the way I need it to, my issue is I want the User to be able to select a record in the sub-form and open it to edit the original entry or add to the information contained in the record. What I would like the User to do is double click on the record in the sub-form they want to edit or add information to. When they double click the original record entry will open (in this case my form frmDaily) in edit mode so they can make their changes.
    My current code for the double click action does not see anything past the first record in the list contained in the sub-form. What do I need to do to be able to over come this issue? Example the list contains 6 records and I double click on the third record in the list. the current code open the first record, I need for it to open the record I have selected ? How can I do this?What modifications do I need to make to my present code to get this to work?

  4. #4
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    I don't understand

    If you are using a bound form you don't need to have your click or double click event open another form to update your data.

    If I understand you correctly, based on my example, if you click something in the list box of the subform you want to open ANOTHER form named frmDaily that lists that record so you can edit it.

    Why open that second form when you don't have to?

  5. #5
    pfales is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2013
    Posts
    23
    I was affraid I was not explaining it correctly.
    Let me try it another way, I use frmDaily as the input form for the table, "tblDaily_Task", this is what is utilized to make the task entries into the table/db. When a User signs in to the application the first window/form the will see is the frmActivity_List which contains the sub-form "sfmActivity_List". The sub-form will show the user all the entries that they have made but nothing that anyone else may have made. What I need to be able to do is select one of the record in the sub-form to edit or update the information in that record. what I would like todo is double click the record and have it open in frmDaily (original entry form) to be updated/edited.

  6. #6
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    Any chance you can post a sample database (preferably something prior to access 2010 I have very, very limited access to 2010)

  7. #7
    pfales is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2013
    Posts
    23
    Unfortunately I am utilizing Access 2010.

  8. #8
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    so post a sample or create a sample and convert it to something prior

  9. #9
    pfales is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2013
    Posts
    23

    Selecting a record from a sub-form

    subform1.mdb

    I have attached the two items you asked for

  10. #10
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    Your sample has two forms, frmActivity_List and sfrmActivity_List.

    It doesn't include your form frmDaily nor does it include any of the tables that you're working with, need those tables included (just put some fake data in there, enough to simulate your environment) as well.

  11. #11
    pfales is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2013
    Posts
    23

    Selecting a record from a subform

    subform2.accdbsubform3.accdb

    Sorry I had to divide it into multiple attachments

  12. #12
    pfales is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2013
    Posts
    23
    subform3.mdbsubform2.mdbsubform1.mdb

    Then on top of that I forgot to rename it to an .mdb, Sorry about that

  13. #13
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    by the way, putting .mdb as an extension does not convert the database, you have to use the utility within 2010 to do it. I'm taking a look at it now.

  14. #14
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    I've combined the parts of your database into the attached file. I don't know why you're putting different objects in different databases for the sample database, but even with the added parts your forms still do not function.

    You've devised a function called fOSUsername that is not defined in your sample database.
    Your user combo box on the form frmActivity_List is referencing a table that is not in your sample database.

    If you add these items into the database I'm attaching then re-post I can take another look.

    subform1.zip

  15. #15
    pfales is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2013
    Posts
    23
    subform1a.zip

    I apologize I should have let it be known that I am not Access Development knowledgeable, actually just trying to learn (self teach kind of) as I go here. The file =fOSUserName() pulls the users name that is logged in to the computer just like the command "=fnGetUserID()" does I just am more comfortable with the first since I learned it first.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Selecting a record for a report
    By TToc2u in forum Reports
    Replies: 1
    Last Post: 03-05-2013, 02:07 PM
  2. Selecting record in foreign table using VBA
    By Jmeyering in forum Programming
    Replies: 3
    Last Post: 11-12-2012, 04:29 PM
  3. Selecting record in subform
    By survivo01 in forum Forms
    Replies: 8
    Last Post: 10-29-2012, 08:30 AM
  4. Replies: 9
    Last Post: 09-16-2011, 03:52 PM
  5. Record Selecting
    By dbprogman in forum Programming
    Replies: 5
    Last Post: 04-27-2011, 10:35 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