Results 1 to 5 of 5
  1. #1
    jaryszek is offline Expert
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2016
    Posts
    568

    Stepping from Main form to subform and deleted records - which event?

    Hi Guys,

    i had a problem like here:



    https://stackoverflow.com/questions/...-into-sub-form

    and i solve the issue using:

    Code:
    Private Sub NumaNodes_AfterUpdate()
    
    
        Dim strSQL As String
        strSQL = CurrentDb.QueryDefs("Copy Of QJunction").SQL
        CurrentDb.QueryDefs.Refresh
        Me.Requery
        
      
    End Sub
    MS Access is a FE to PostgreSQL BE.

    I do not know why me.refresh is not working here (still records are deleted from Main form).

    Code is working fine but this is only for one combobox.

    I have 5 comboboxes and i do not want to repeat code for each of them -
    i would like to have code something like that:

    For selected combobox (check which one) do after_update event.

    Or when i am clicking to subform field i want to fire event, but i do not know which event (so before focus).

    Please help,
    Best,
    Jacek

  2. #2
    Gicu's Avatar
    Gicu is offline VIP
    Windows 8 Access 2013
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,235
    Hi Jacek,
    Have you tried the OnExit event of the main form?
    Cheers,
    Vlad

  3. #3
    Gicu's Avatar
    Gicu is offline VIP
    Windows 8 Access 2013
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,235
    Sorry, I meant the OnExit of the last control on the main form. But not quite sure of the problem. You're saying that editing the combo-boxes (which are bound to fields in the parent side of the query) and then moving to the subform produces the "data has been changed" error?
    Vlad

  4. #4
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,372
    Which event would depend on what it is you're trying to accomplish. Maybe Current event of the subform? I've read it a few times and can't figure that out.

    As for the first part, if the action for each combo is pretty much the same, then create a function and pass to it whatever you need to. You can pass the combo name, it's value, it's old value, a column value, a pair/set of variables or values, etc. etc. But I can't figure that out either because after looking at your code, it seems that all it does is assign the sql of a stored query to a variable (strSQL) then does nothing with it. I don't see how that could modify the stored query's sql property, so what is there to refresh?
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    jaryszek is offline Expert
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2016
    Posts
    568
    Hi Guys,

    thank you for your answers. passing to function is good idea Micron.

    Vlad there where problem because data in Back End - postgres was not automatically loaded.
    After resreshing tables (using code) all worked.
    I think that when Access would be the BE it will work fine.

    I solve the problem creating one another subform (so one main and 2 subforms).
    When user is inputing data into subform 1 VBA code is resreshing main subform and going exactly to the ediding record.

    It is working,
    thank you!

    Jacek

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

Similar Threads

  1. Replies: 3
    Last Post: 09-28-2016, 07:36 AM
  2. Subform not gathering all records from Main Form
    By compstudent in forum Access
    Replies: 1
    Last Post: 03-05-2015, 01:07 PM
  3. Replies: 2
    Last Post: 12-07-2014, 01:15 PM
  4. Replies: 2
    Last Post: 06-09-2012, 01:56 AM
  5. Call a subform event from the main form
    By bonecone in forum Programming
    Replies: 2
    Last Post: 05-02-2012, 11:36 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