On_Dirty Form Event

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form and I want to place an UPDATE statement in an On_Dirty form
event. I understand that it should fire when the record contained in the form
has been modified, but it doesn't appear that it is. The reason I say this is
that I have constructed an UPDATE statement with a message box that displays
the UPDATE statement in a procedure that should execute when I have modified
the record in the form, but the message box doesn't show up when I modify the
record. Am I doing something wronge?

Below is a copy of my local procedure:

Private Sub Form_Dirty(Cancel As Integer)

Dim strSQLstmt As String

strSQLstmt = "UPDATE Development_Disabilities_Master_Test " & _
"SET PatientLstName = " & "'" & Me![PatientLstName] & "', " & _
"PatientFrstName = " & "'" & Me![PatientFrstName] & "', " & _
"PatientMdlName = " & "'" & Me![PatientMdlName] & "', " & _
"Gender = " & "'" & Me![gender] & "', " & "DateOfBirth = " &
Me![DateOfBirth] & "', " & _
"ParentLstName = " & "'" & Me![PatentLstName] & "', " & _
"ParentFrstName = " & "'" & Me![PatentFrstName] & "', " &
"Phone = " & Me![phone] & _
"ParentStrtAddress = " & "'" & Me![ParentStrtAddress] & "', "
& _
"ParentCity = " & "'" & Me![ParentCity] & "', " &
"ParentState = " & "'" & Me![ParentState] & "', " & _
"ParentZip = " & "'" & Me![PatentZip] & "', " & "UnitNum = "
& "'" & Me![UnitNum] & "', " & _
"AgeAtEval_Years = " & Me![AgeAtEval_Years] &
"AgeAt_Eval_Mnths = " & Me![AgeAt_Eval_Mnths] & _
"Lives_With = " & "'" & Me![Lives_With] & "', " & "Pediatrics
= " & "'" & Me![Pediatrics] & "', " & _
"Audiology = " & "'" & Me![Audiology] & "', " & "SpeechLang =
" & "'" & Me![SpeechLang] & "', " & _
"Psychology = " & "'" & Me![Psychology] & "', " & "CDDEval =
" & "'" & Me![CDDEval] & "', " & _
"PrimDiag = " & "'" & Me![PrimDiag] & "', " & "IntelFunct = "
& "'" & Me![IntelFunct] & "', " & _
"Adaptive_Level = " & "'" & Me![Adaptive_Level] & "', " & _
"Social_Familial = " & "'" & Me![Social_Familial] & "', " & _
"Strengths = " & "'" & Me![Strengths] & "', " & _
"Disciplines_Present = " & "'" & Me![Disciplines_Present] &
"', " & _
"Comments = " & "'" & Me![Comments] & "' " & _
"WHERE DevelopDisabil_ID = " & Me![DevelopDisabil_ID] & _
"AND Tnchp_Profile_ID = " & Me![Tnchp_Profile_ID] & ";"

MsgBox "UPDATEing Development_Disabilities_Master_Test table strSQLstmt =
" & strSQLstmt

End Sub
 
You should only use the update command within a recordset

For example:

set rs = db.openrecordset("MyTable")
with rs

.edit
!MyField = MyValue
.update

end with
rs.close
set rs=nothing

HTH

Steve
 
Back
Top