Results 1 to 6 of 6
  1. #1
    Join Date
    Mar 2012
    Posts
    28

    Unanswered: Changing what is displayed on main form when subform is closed

    Hi. I am working on an Access database that contains a table called "Maps" and another called "Products".

    The main form lists the "maps" from a selected "product".

    I have built another form that opens as a dialog box from the main form, that allows the user the duplicate "maps" from an existing product into a brand new product. When the user closes this form I'd like the main form to automatically open the new "product" that was just created. Is this possible?

    Thanks

  2. #2
    Join Date
    May 2012
    Posts
    89
    Hi joshuag

    Maybe this is what your looking for...

    If you use an autonumber for the records Primey Key
    For the dialog box:

    Private Sub Form on_Close ()
    Forms!Mainform.Requery
    End Sub


    or if you use an button with a Private sub then put the: Forms!Mainform.Requery ... in it

    And for the main form:

    Private Sub Form after_update()
    Docmd.GoToRecord , , LastRecord
    End Sub

  3. #3
    Join Date
    Mar 2012
    Posts
    28
    Thanks Rubberducksucker but it didn't do anything.

    Is LastRecord the same as acLast? I tried that as well as acFirst but the only that worked was the requery.

  4. #4
    Join Date
    Mar 2012
    Posts
    28
    Is there any other way I could get it to work? I've tried numerous ways.

    Thanks

  5. #5
    Join Date
    May 2012
    Posts
    89
    Hi Joshuag.

    Sorry for the late response.

    Your write about the code it should be:
    -DoCmd.GoToRecord , , acLast-

    Also couse you have your main form (that you want to be updated) based on the "Maps" table sins they are added to an other record the code to go to the last record is based on an old record and so the code:
    -DoCmd.GoToRecord , , acLast-
    wil not work. i din't read it correct...sorry bout that....

    Someting out of my head if you add an Date/Time collum to the Products table call it something like: "Updated"

    Private Sub Form_Open(Cancel As Integer)
    Me.Updated.value = Now()
    End Sub

    Preferably i would disable this field.

    And base you "Mainform" to an Query from the "Products" table and sort them on the field "Updated" and then with the code:
    Forms!Mainform.Requery
    On the confirm of closing/saving the dialog box.

    Im not in the possibility of testing this so ill hope to hear from you when it is or is not working.

  6. #6
    Join Date
    Mar 2012
    Posts
    28
    Hi. I finally got it working. In the After_Update event of the "Create Duplicate Product" form I have to code

    Code:
    Forms!BM_Product.Requery
    
    Dim SearchID As Variant
    
    SearchID = Me.DUP_PRODUCT_ID
    
    Forms!BM_Product.Prod_ID.SetFocus
    
    DoCmd.FindRecord SearchID, acEntire
    works great.

    Thanks for your help anyway.

Tags for this Thread

Posting Permissions

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