How to open form2 and then return to the same previous record in form1?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • neelsfer
    Contributor
    • Oct 2010
    • 547

    #1

    How to open form2 and then return to the same previous record in form1?

    I open a 2nd form called "Fis_StEdit F" from the subform where i am currently capturing called
    "[Forms]![stocktakeF]![Fis_StocktakeSF]",
    using the code below, where "icn" is the same for both.

    This works and i go to the correct record.

    Code:
    DoCmd.OpenForm "Fis_StEditF", acNormal, "", "[icn]=" & "" & Icn & "", , acNormal
    On pressing the Close button in the "Fis_StEdit F" form, i want to return to the same line (last record captured) in "[Forms]![stocktakeF]![Fis_StocktakeSF]", where i was busy capturing before i went to "Fis_StEdit F"
    The main "field" in "Fis_StocktakeS F" is called "item_looku p"
    pls help.
  • neelsfer
    Contributor
    • Oct 2010
    • 547

    #2
    In the previous post i opened the "Fis_StEdit F" form and it showed the correct record. Now I would like to return to the last record in the "Fis_StocktakeS F" where i came from, to update the current table with that last record.
    I am struggling with this setfocus as it moves to the next blank record when i update via me.name = me.name function and add this blank record to the table.
    I have an Id field called STId in both tables, that is the same and can be used as a reference to refer to each other.

    Code:
    Private Sub upd_Click()
    On Error GoTo upd_Click_Err
    [Forms]![stocktakeF]![Fis_StocktakeSF].SetFocus
    DoCmd.GoToRecord , , acLast
    Bincard_Total = [Forms]![stocktakeF]![Fis_StocktakeSF]![Bincard_Total]
    BeginStock = [Forms]![stocktakeF]![Fis_StocktakeSF]![BeginStock]
    FirstCount = [Forms]![stocktakeF]![Fis_StocktakeSF]![FirstCount]
    SecondCount = [Forms]![stocktakeF]![Fis_StocktakeSF]![SecondCount]
    ConfirmedCount = [Forms]![stocktakeF]![Fis_StocktakeSF]![ConfirmedCount]
    
        DoCmd.RunCommand acCmdRefresh
    upd_Click_Exit:
        Exit Sub
    
    upd_Click_Err:
        MsgBox Error$
        Resume upd_Click_Exit
    
    End Sub

    Comment

    Working...