Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  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 values

    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 my form is an option button frame that lets the user select (1) of several records in a second table [tbl...]
    the record in the first table [tbe...] is then replaced with 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 code: "me.requery" to the after update event; that did not produce favorable results either...

    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.Requery
    DoCmd.SetWarnings True

  2. #2
    NTC is offline VIP
    Windows Vista Access 2007
    Join Date
    Nov 2009
    Posts
    2,392
    did you try me.refresh?

  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
    just tried me. refresh, and it wasn't the answer

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

  4. #4
    pkstormy's Avatar
    pkstormy is offline Access/SQL Server Expert
    Windows XP Access 2003
    Join Date
    Mar 2010
    Location
    Madison
    Posts
    682
    Try me.repaint

    This refreshes the form with changes of caption boxes and other controls on the form.

  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
    hmpft!, now i'm really stumped

    at least .refresh gave me a form with null values;
    .repaint, seems to have no action (this makes no sense to me, and i wonder if i ought to be looking for some other "issue" ? )

  6. #6
    pkstormy's Avatar
    pkstormy is offline Access/SQL Server Expert
    Windows XP Access 2003
    Join Date
    Mar 2010
    Location
    Madison
    Posts
    682
    me.repaint doesn't refresh your text box values, only things like caption box changes and non data value controls.

  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
    the action I'm having trouble with is:

    form: Main Menu
    tab: Reports
    command button: Additional print Options
    form: Fixtrue Schedule Print Options
    option button group: Preset schedule Options (top left side of menu)

  8. #8
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    base on my understanding, PkstormY were in the wrong way of what Mark wants.

    Mark:

    Since you delete all the records in the table (actually only one record) as following code, for sure you get all nulls values on the form afte refresh because the form is link to the table. Nothing in the table leads to nulls in the form.
    sSQL = "Delete * from [tbeFixtureSchedulePrintOptions];"
    DoCmd.RunSQL sSQL
    actully, you don't need any code to accomplish that. create a combo box in you form with data from your second table, set control source to the field of the first table. then that's it. when ever the user change the selection in the combo box, it save to the first table.

  9. #9
    markjkubicki's Avatar
    markjkubicki is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jul 2010
    Location
    Fire Island Pines, NY
    Posts
    496
    not sure how all of the other fields in the first table will be updated, but let me play with it for a while...

    (BTW, while choosing a value in the combo box or the option group will set the default values for the remainder of the table; the user will still needs to have the right ot override the defaults at any time; these overrides are then stored in the first table (the default values aree in the 2nd)

  10. #10
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    If you want the user has the right to type in any value, please set the combo box property "Limit to list" to false.

  11. #11
    markjkubicki's Avatar
    markjkubicki is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jul 2010
    Location
    Fire Island Pines, NY
    Posts
    496
    (the combo box would be the one control on the form that i do not want the user to have cchoice (these are only to be recommended setting for the options on the form (its other controls), and those preset options are being determined by a higher power :-)

  12. #12
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    I am confused.

    you can work on you original codes as you first post, but don't use update instead of delete.,

  13. #13
    markjkubicki's Avatar
    markjkubicki is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jul 2010
    Location
    Fire Island Pines, NY
    Posts
    496
    hmmm "update" that's new command for me, I'll play with it later today

    (BTW, you did notice that there is a line of code after the line that deletes a record to then add a record. the me.refresh command happens after that -so wouldn't the form be refreshing to the recently added record, not the state inbetween where there is none?.

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

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

    'Me.Refresh

  14. #14
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    but what you added was base on the table which you just deleted all records, hence there must be nothing you can get.

  15. #15
    markjkubicki's Avatar
    markjkubicki is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jul 2010
    Location
    Fire Island Pines, NY
    Posts
    496
    that shouldn't be true
    I am inserting from the table TBE... (based on the selection of the option group) from the table tbL... the records from tbL... ought to never be delted, only those from tbE...

    did I code something backwards?

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Form Updating
    By stevman22889 in forum Forms
    Replies: 3
    Last Post: 07-20-2010, 12:07 PM
  2. updating a table from a form.....
    By softspoken in forum Access
    Replies: 7
    Last Post: 04-21-2010, 09:04 AM
  3. Replies: 3
    Last Post: 04-04-2010, 05:26 PM
  4. combo not updating form
    By cjamps in forum Forms
    Replies: 5
    Last Post: 04-14-2009, 12:00 PM
  5. Updating SQL server form Access form?
    By slash75 in forum Forms
    Replies: 1
    Last Post: 09-06-2008, 02:39 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