Results 1 to 6 of 6

Thread: Will Dirty work

  1. #1
    Join Date
    Feb 2004
    Location
    UK
    Posts
    246

    Question Unanswered: Will Dirty work

    Hi,
    I have a continuous form that when the user hits a command button to exit the form, it fires off a macro. I want this macro to only fire off certain update queries if any data has been changed on the form.

    Can I use the forms OnDirty event to do this and how can I incorporate it into the macro, ie if the form has changed then run the whole of the macro, if nothing has changed follow only certain parts of the macro.

    Regards
    John
    Last edited by Sticker; 03-25-04 at 05:58.

  2. #2
    Join Date
    Feb 2004
    Location
    UK
    Posts
    246
    Any thooughts would be greatly appreciated

  3. #3
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    you can use the dirty event to set a var (or what i do is check a tickbox called mustSave on the form - the box is hidden for "production" but is helpful to see it for development)

    then, before your user moves off the record/form or hits a menu or whatever.
    if mustSave then ...run your save routine

    izy
    currently using SS 2008R2

  4. #4
    Join Date
    Feb 2004
    Location
    UK
    Posts
    246
    Thanks Izy,
    I've put a check box in the footer (called mustsave) and in the form OnDirty event I have said to populate it.

    Can I just confirm what the syntax would be.

    Private Sub Form_Dirty(Cancel As Integer)
    Me.mustsave.Value = 1
    End Sub

    is that right?

    Sorry as I know nothing about VB, only what I have picked up on this forum !

    Regards
    John

  5. #5
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    please dont use numeric values: there are intrinsic constants for this kind of thing which avoid any risk of confusion.

    Private Sub Form_Dirty(Cancel As Integer)
    me.mustsave = True
    End Sub

    i killed the .value (a question of taste, but .value is the default property of a checkbox or textbox so it is not necessary)

    ...also, you will want to set the properties¦data¦default for this checkbox to False so the form starts-up with no need to save.

    ...final also, your save routine should include
    me.mustsave = false


    izy
    currently using SS 2008R2

  6. #6
    Join Date
    Feb 2004
    Location
    UK
    Posts
    246
    Izy,
    Thank you so much, that works like a dream, also thanks for the last little tip about resetting the check box

    Regards
    John

Posting Permissions

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