Results 1 to 7 of 7
  1. #1
    markjkubicki's Avatar
    markjkubicki is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jul 2010
    Location
    Fire Island Pines, NY
    Posts
    496

    updating a form with new data

    I have a form (with several controls: checkboxes, option buttons...), that displays only (1) record, and gets it's data from a table [tbe...] that also has only (1) record



    on that same form is an option button frame that lets the user select (1) of several records in a second table [tbl...] (This second table provides a various "default" combinations for the the values on the form; so that when the user changes the preset opt, the form reflects those new "default" values.)
    The record in the first table [tbe...], which is the data source for the form, is then replaced with a record that reflects the user's choice from the 2nd [tbl...]

    ...all of this works fine, but what I can't get to work, is an action that updates the controls on the form

    I also tried moving the me.Refresh from the beforeUpdate to afterUpdate
    it's closer to being right, but the form only updates to null values -as if the added record hadn't arrived yet... (timing?)

    many thanks in advance,
    mark




    here's the code:
    ---------------------------------------

    Private Sub frmPresetOption_beforeUpdate(Cancel As Integer)
    Dim sSQL As String
    DoCmd.SetWarnings False

    sSQL = "Delete * from [tbeFixtureSchedulePrintOptions];"
    DoCmd.RunSQL sSQL

    sSQL = "INSERT INTO tbeFixtureSchedulePrintOptions" _
    & " SELECT *" _
    & " from tblFixtureSchedulePrintOptions" _
    & " WHERE [PresetOption] = " & Me.frmPresetOption & ";"
    DoCmd.RunSQL sSQL

    Me.Refresh
    DoCmd.SetWarnings True
    ...


    -----------
    also:
    Private Sub frmPresetOption_afterUpdate(Cancel As Integer)
    me.refresh
    ...

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,530
    Have you tried

    Me.Requery

    instead of Refresh? Requery is what you want. Refresh only shows changes made to records already in the current recordset.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    markjkubicki's Avatar
    markjkubicki is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jul 2010
    Location
    Fire Island Pines, NY
    Posts
    496
    i've tried both (in combi9ation and seperately)... maybe in the wrong combination?

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,530
    The Refresh should not be required at all, the Requery should get the new record. If it's a timing issue, you can see if putting

    DoEvents

    between the insert and the requery helps.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    markjkubicki's Avatar
    markjkubicki is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jul 2010
    Location
    Fire Island Pines, NY
    Posts
    496
    AURGH!! still not it (?!)

    so I added...

    Private Sub frmPresetOption_afterUpdate()
    DoEvents
    Me.Requery
    End Sub

    i'm still getting an updated form with aLl the values at null (all of the checkboxes, etc are greyed out)

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,530
    Can you post the db?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    markjkubicki's Avatar
    markjkubicki is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jul 2010
    Location
    Fire Island Pines, NY
    Posts
    496
    I'm a little slow at figuring out how to post the applicable parts of a Db; and will try to do so later tonight (at the latest tomorrow AM)

    thanks for your interest.

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

Similar Threads

  1. Importing and updating data.
    By mikej2009 in forum Import/Export Data
    Replies: 1
    Last Post: 05-23-2010, 11:30 AM
  2. Updating data within a form/table.....
    By softspoken in forum Forms
    Replies: 3
    Last Post: 04-15-2010, 06:33 PM
  3. Exporting and Updating exported data
    By Singapore Sam in forum Import/Export Data
    Replies: 2
    Last Post: 12-15-2009, 09:33 AM
  4. Replies: 3
    Last Post: 04-27-2009, 02:29 PM
  5. Replies: 1
    Last Post: 02-10-2009, 09:57 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