Results 1 to 7 of 7
  1. #1
    TAM is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2015
    Posts
    22

    How to carry forward a record ID to subform to ensure editing the right record

    I am having difficulty getting the right record to carry forward into a modal subform to edit/update information.




    The Request_nmbr is an autonumber field. The client can have multiple requests. When I open my subform, I can scroll through the records, but when I launch the "update" button, I don't know how to carry forward the request_nmbr so that I'm updating the right record.

    Here's my code:
    Private Sub Btn_Exception_SubModal_Click()
    DoCmd.OpenForm "Frm_Exception_UpdateModal", acNormal, , acFormAdd

    Forms! [Frm_Exception_UpdateModal]![Request_nmbr].value = Me![Request_nmbr].value
    Forms! [Frm_Exception_UpdateModal]![clientnmbr].value = Me![clientnmbr].value
    End Sub

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    I dont see any updates needed. In the form , once you save the record, the form will show the autonumber.

  3. #3
    TAM is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2015
    Posts
    22
    Hi. Thanks again for your help today! I want to clarify. As an example, I created a record two weeks ago for client "Jones" and another record last week for the same client and then another record today for the same client. My main form allows me to search for the client. I can scroll through/view all 3 records. As an example, I'd like to update the second record for the status. I was thinking that the auto number along with the client ID would be needed in the subform to make sure I'm updating the right record.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    So your 'modal subform' is not really a subform - it is an independent form that is called from the main form?

    Use the WHERE CONDITION argument to open 'subform' to the desired record.

    The code you show is opening form to a new record and is then setting values of fields of new record. This is not finding an existing record for editing.
    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
    TAM is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2015
    Posts
    22
    You're correct. Can you help me with the code for the "Where condition" argument to open the form with the existing data?

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    Something like:

    DoCmd.OpenForm "Frm_Exception_UpdateModal", , , "Request_nmbr=" & Me.Request_nmbr

    Is Request_nmbr a text type field?

    DoCmd.OpenForm "Frm_Exception_UpdateModal", , , "Request_nmbr='" & Me.Request_nmbr & "'"
    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.

  7. #7
    TAM is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2015
    Posts
    22
    Thank you! That was the answer I needed and it worked.

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

Similar Threads

  1. Replies: 1
    Last Post: 02-26-2015, 11:31 AM
  2. Replies: 8
    Last Post: 01-13-2015, 10:27 PM
  3. Ensure the form I'm on is last record
    By zippy483 in forum Programming
    Replies: 1
    Last Post: 11-23-2011, 05:08 AM
  4. Carry value over to new record w/macro
    By bbrazeau in forum Programming
    Replies: 5
    Last Post: 10-27-2011, 09:00 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