Results 1 to 15 of 15
  1. #1
    gstylianou is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Dec 2013
    Posts
    167

    update fields in main form without having to re-open the man form for re-query

    Good evening to all,


    I have a form that gets data from a query (qryCustomers) and has a built-in command button (cmdInvoices) which opens the form "frmInvoices". I want after the update of some fields in the second form (frmInvoices which is pop-up-form) the related fields in the main form to be updated directly without having to close and open again so it becomes requery.



    It is understood that after the update in the main form and when the re-query finish, I want to produce the same record

    Regards

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,633
    Requery/Refresh always sets focus on first record of form. So unless the form RecordSource has a parameter for filtering to a single record, will have to somehow return to the record. This will probably require saving ID to a global variable (declared in module header or by TempVars) and using that to reset focus to desired record.
    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.

  3. #3
    gstylianou is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Dec 2013
    Posts
    167
    First all, i would like to thank you for your reply.

    But, as i'm not expert can you please write me a sample code in order to modify it in my case?

    Thanks again

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,633
    Bing: access requery form and return to record

    Review:
    http://bytes.com/topic/access/answer...-return-record

    Correction, looks like global declaration not really needed, just procedure declaration. Something like:

    Dim intID As Integer

    intID = Me.ID

    DoCmd.OpenForm "formname", , , , , acDialog

    Me. Requery

    With me.RecordsetClone
    .FindFirst "ID=" & intID
    Me.Bookmark = .Bookmark
    End With
    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
    gstylianou is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Dec 2013
    Posts
    167
    Good Morning June7,

    Unfortunately it doesn't work..

    I wrote the following code in order 1st) to close the popup form which the calculated fields are embedded and 2) in order to return to the parent form and requery.

    Private Sub Form_Close()


    DoCmd.OpenForm "FrmCustomers" (this is the parent form)


    Dim RecId As Long


    RecId = Me.Code (this field is autonumber field which is embedded in child popup form)


    Me.Requery


    With Me.RecordsetClone
    .FindLast "Code" & "=" & RecId (i want going to the last)
    Me.Bookmark = .Bookmark
    End With

    DoCmd.Restore
    End Sub
    Last edited by June7; 06-11-2014 at 12:40 AM. Reason: corrections

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,633
    Not quite following the code example I posted.

    Need to declare and set the variable before opening the popup form. Don't want the record ID from popup form. Need record ID from the first form.
    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
    gstylianou is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Dec 2013
    Posts
    167
    Hi June7,

    Really appreciate your help. Unfortunately i cannot to that..its beyond my knowledge in vba. I will appreciate if you can write me a sample code in order to try..

    Thanks in advanced

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,633
    I already wrote sample code in post 4.
    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.

  9. #9
    gstylianou is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Dec 2013
    Posts
    167
    June7,

    I tried the following code......but......nothing

    Dim intCode As Integer
    intCode = Me.Code


    DoCmd.OpenForm "frmCustomers", , , , , acDialog


    Me.Requery


    With Me.RecordsetClone
    .FindLast "Code=" & intCode
    Me.Bookmark = .Bookmark
    End With

    Any idea?

  10. #10
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,633
    That is my idea. I don't know your db so can't really be more specific.

    What do you mean by 'nothing'? No error and no results? Refer to link at bottom of my post for debugging guidelines.

    My sample code used FindFirst, you are using FindLast. I have never used FindLast but I suppose as long as only one record meets the condition, should work as well.
    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.

  11. #11
    gstylianou is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Dec 2013
    Posts
    167
    Good morning June7,

    I tried this code on the "On Close" event of the child form and i'v just seen nothing to doing.. no filtering to the record. Please note that, the parent form taking values from query..... Maybe is that problem for filtering?

    Regards

  12. #12
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,633
    The query is form RecordSource? That should be okay.

    At this point I am just making wild guesses. If you want to provide db for analysis, follow instructions at bottom of my post.
    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.

  13. #13
    gstylianou is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Dec 2013
    Posts
    167
    Good morning June7,

    The query is the form Record Source. Can you please a suggest anything?

    Thanks in advanced

  14. #14
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,633
    Suggestions already given are all I have. Read post 12 again.
    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.

  15. #15
    gstylianou is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Dec 2013
    Posts
    167
    June7 the problem has been solved.

    I just write the code Forms!frmCustomers.Requery on the "OnClose" event of the child form.

    Anyway, thank you again

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

Similar Threads

  1. Update fields from subform to main form
    By gstylianou in forum Access
    Replies: 4
    Last Post: 06-10-2014, 12:59 AM
  2. Select all query fields for main form?
    By tagteam in forum Access
    Replies: 13
    Last Post: 09-15-2013, 04:35 PM
  3. Replies: 1
    Last Post: 07-20-2012, 09:48 AM
  4. Replies: 3
    Last Post: 03-11-2012, 08:24 PM
  5. Replies: 11
    Last Post: 01-26-2012, 01:22 PM

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