Results 1 to 5 of 5
  1. #1
    injanib is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jan 2011
    Posts
    67

    Updating an Existing Record Via an Unbound Form

    Hi all,



    I have a continuous form. I use an unbound form to enter record in the underlying table of this continuous form and then requery the form. Each row on the continuous form also has a "delete" button and "modify" button. The delete button simply deletes the record in that row. What I want to do is to use the modify button to populate the record in that row on the unbound form I use to write record in the underlying table. Basically, I click on the "modify" button on a row, and it opens up the unbound form with the record in its respective row populated. I make the changes and then hit save. It writes the data back in the underlying table and requery the form. That way, the primary key doesn't change, only the data is modified.

    Is it possible?

    Thanks in advance

  2. #2
    nicknameoscar is offline Advanced Beginner
    Windows XP Access 2000
    Join Date
    Apr 2011
    Location
    Earlysville, VA
    Posts
    91
    If I am understanding the question correctly then, yes, it is possible. You would have to make sure the record you want to modify is selected (record selector has black triangle or you otherwise know which record is the selected record).

    The below assumes the unbound form is already open:

    Private Sub cmdModify_Click()

    Dim frm as Form
    Set frm = frmUnboundForm

    frm.txtObject1 = Me.txtObject1
    frm.txtObject2 = Me.txtObject2
    etc.
    .
    .
    .
    End Sub

    If the unbound form isn't open then perhaps something like this:

    Private Sub cmdModify_Click()

    DoCmd.OpenForm "frmUnboundForm"

    (insert code from above)

    DoCmd.Close acform, "frmBoundContiuousForm"

    End Sub

  3. #3
    injanib is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jan 2011
    Posts
    67
    That was too easy. I can now populate the information. Just need to run an update query to write back the changes.

    Thanks allot.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Glad you have solution but not understanding why using an unbound form. Why go through all this manipulation when a bound form could be opened to the existing record and edits can be accomplished then the calling form can be refreshed. How would this change the primary key?
    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
    blueraincoat is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Mar 2011
    Location
    Shanghai,CHN
    Posts
    99
    Code:
    Private Sub Command8_Click()
    Dim mySQL As String
        mySQL = "UPDATE tbl SET tbl.C='" & Me.C & "',tbl.D='" & Me.D & "'"
        mySQL = mySQL & " Where tbl.A='" & Me.A & "'"
            Debug.Print mySQL
            CurrentDb.Execute mySQL, dbFailOnError
    End Sub

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

Similar Threads

  1. Replies: 0
    Last Post: 02-25-2011, 09:40 AM
  2. Updating an Existing Table
    By jo15765 in forum Access
    Replies: 2
    Last Post: 11-21-2010, 09:11 PM
  3. Replies: 3
    Last Post: 08-17-2010, 02:24 PM
  4. Replies: 0
    Last Post: 10-14-2009, 02:44 AM
  5. Find existing record with multiple criteria
    By TheWedgie in forum Forms
    Replies: 1
    Last Post: 03-25-2009, 10:24 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