Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 2006
    Posts
    6

    Question Unanswered: Tab Control and Form Updating

    Hi

    I wish to know how to prevent a form before update and after update event from occurring when moving between pages on a tab control.

    I have a form which consists of a tab control with a few pages. When I change a fields data (say on page 1) then move to another tab page then the record is actually saved and the before update and after update events are fired. This only appears to happen when the page being tabbed to contains a subform.

    I have code in the before and after update events but if all I'm doing is changing tab pages then I dont want this code to fire. Actually at this point I dont even want the record saved which seems to be the case

    Can somebody please help

    Thanks
    Last edited by rick_mnzm; 08-27-06 at 17:57. Reason: Visibility enhancement

  2. #2
    Join Date
    Apr 2004
    Location
    outside the rim
    Posts
    1,011
    You may get away with putting some sort of check (literally a hidden check box on your form) that you set true or false at different times so that you can add a line to your before and after update events to stop them from being carried out, but preventing the data from being updated is not likely.

    If you want to over-ride the build in sequence of events surrounding the movement of data between the form and table, you'll have to make it unbound and handle the data movement yourself.

    This is daunting at first, but not so bad after you get the hang of it.

    tc

  3. #3
    Join Date
    Aug 2006
    Posts
    6
    tc - thanks

    I've tried similiar by setting a module variable false in the OnCurrent event. I then set the variable true in the Tab Control OnChange event. In the forms BeforeUpdate I checked the variable and if it was true then cancelled the BeforeUpdate.

    However the Forms BeforeUpdate fired before the TabControl OnChange so this did not work.

    Can you expand a bit on your check box idea please. When would it be set true or false

    I'll look at your other option also and see just how much code changing I need to do.

    I've also noted that the problem does not occur if I use a linked form for the sub data so I might look also at doing that instead of using a form/subform

  4. #4
    Join Date
    Apr 2004
    Location
    outside the rim
    Posts
    1,011
    Can you expand a bit on your check box idea please. When would it be set true or false
    It's much the same as using a public variable, just more appropiate for this case. The Yes/No check box serves as a form based boolean variable.

    A nice clean trick to using code to move data on and off an unbound form is to use a query that has the specific fields on the form, name all the controls on the form to match the field name of the query and then simply use a For Each ... Next loop on the queries Fields collection to grab the data.

    Code:
    rsData.Edit
    For Each fld In qry.Fields
        rsData(fld.Name) = Me(fld.Name)
    Next
    rsData.Update
    fld is a DAO.Field object
    qry is a DAO.QueryDef object set to your query
    rsData is a recordset to your query

  5. #5
    Join Date
    Aug 2006
    Posts
    6

    thanks

    Hi TC,

    I sorta lost the thread there for a while.
    I forgot to say thanks for your replies

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •