Results 1 to 6 of 6
  1. #1
    Star Lounger
    Join Date
    Mar 2002
    Location
    Ventura, California, USA
    Posts
    56
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Update Form (2002)

    Hey Gang,

    I have a Form for reviewing data in a table with an update button that opens a pop up form for adding and or modifying the data in the table. The problem I am having is that when the update for Pop's up it defaults to the first record. I want it to stay on the record the user was reviewing when they hit the update button. I cannot for the life of me find the code that keeps the record the same.

    Any help would be appreciated.

    Dan

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Update Form (2002)

    Do you want all records to be visible in the popup form, with the current record on the calling form as the current record in the popup form too, or do you want the popup form to display only the "current" record?

  3. #3
    Star Lounger
    Join Date
    Mar 2002
    Location
    Ventura, California, USA
    Posts
    56
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Update Form (2002)

    I want the popup form to open up to the current record on the calling form.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Update Form (2002)

    I'm sorry, that is not an entirely unambiguous answer to my question.

  5. #5
    Star Lounger
    Join Date
    Mar 2002
    Location
    Ventura, California, USA
    Posts
    56
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Update Form (2002)

    I want all records to be visible in the popup form, with the current record on the calling form as the current record in the popup form too.

    Sorry about the vagueness.

    Dan

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Update Form (2002)

    Thanks for clearing that up. You need a unique identifier for the current record; an AutoNumber field is ideal for this, but it can also be another type of field, or even a combination of fields. In the example below, I have assumed that you have a numeric field ID that acts as unique record identifier. The On Click code for the update button could look like this, with the appropriate names substituted.

    Private Sub cmdUpdate_Click()
    DoCmd.OpenForm FormName:="frmPopup", WhereCondition:="[ID]=" & Me.[ID], WindowMode:=acDialog
    End Sub

    If the ID field is text, the value must be enclosed in quotes: use "[ID]=" & Chr(34) & Me.[ID] & Chr(34) as WhereCondition. Chr(34) is the code for the double quote ".

Posting Permissions

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