[AccessD] Code help please

Darren DICK d.dick at uws.edu.au
Mon Apr 5 23:28:31 CDT 2004


Hi Joe
Try something like this
Under the 
Compare Database and option explicit declarations type
gIntFormIsDirty as integer
Then add

Private Sub Form_Load()
gIntFormIsDirty  = False
end sub

then add

Private Sub Form_Dirty(Cancel As Integer)
gIntFormIsDirty  = true
End Sub

then 

Private Sub ps_SomeCodeToRun()

'Joe get whatever the PK is and see if there is a value in it
    if not isnull(Me.MyPK) then 'There is  a value so we are on a live record
        if gIntFormIsDirty  = true THEN
            Msgbox "we are on a pre-existing record and the record is dirty"
        else
            Msgbox "we are on a pre-existing record but the record IS NOT  dirty"
        end if
    else
        msgbox "We are on a 'new rec' or at least one without a PK"
    end if

end sub

then in the afterupdate(or whatever) of the control to test

Private sub txtLastName_AfterUpdate()
ps_SomeCodeToRun
end sub

Hope this helps

----- Original Message ----- 
From: "Joe Hecht" <jmhla at earthlink.net>
To: "AccessD" <AccessD at databaseadvisors.com>
Sent: Tuesday, April 06, 2004 1:18 PM
Subject: [AccessD] Code help please


> This code is supposed to
> 1.       Confirm this is an existing record
> 2.       If the form is dirty 
>  
> Open a message box
>  
> I need vb yes. I want to go to the next record.
>  
> Can not find the right method
>                         
>  
> Thanks  
>  
> Joe
>  
>  
>  
> Private Sub Form_Dirty(Cancel As Integer)
>  
>     if me.newrecord = false and
>     If Me.Dirty Then
>     Dim lngRetval As Long
>  
>     lngRetval = MsgBox( _
>         "Data on this form has changed! " & vbCrLf & "" & vbCrLf & "Do
> you wish to continue?", _
>         vbYesNoCancel + vbQuestion + vbSystemModal + vbDefaultButton1, _
>         "Data Has Changed")
>  
>     Select Case lngRetval
>         Case vbYes
>         
>         Add New RECORD
>             
>         Case vbNo
>          Forms!frmmasterAddresses!txtLastName.SetFocus
>         
>         
>         
>         Case vbCancel
>         
>            
>             
>     End Select
>     
>    End If
>       
>         
>  
>  
>  
> End Sub
>  
>  
>  
> -- 
> _______________________________________________
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com



More information about the AccessD mailing list