Automatic Date Update In Form...

  • Thread starter Thread starter Goobz
  • Start date Start date
G

Goobz

Hey all...

First off, thanx for the help that you all tend to give from this
forum. I have captured a lot of good stuff, and for the 1st time, am
posting asking myself for your help... Here's what I have going on...

I have a form that has approx. 13 field in it. Fields 1-12 are user
inputable via Combo Boxes, or straight typing. Box 13 is locked, and I
would like to have it update when someone changes ***ANY*** of the
other 12 boxes. I **DO NOT** want to track simple record pull-ups...

I cleaned up the Events page, and here is the latest... The only thing
that is an [Event Procedure] is the current "search" button I have
embedded on the page... Please let me know what I need to change to
include the record save.

-------------------------------
Option Compare Database

Private Sub Search_Button_Click()
On Error GoTo Err_Search_Button_Click

Screen.PreviousControl.SetFocus
DoCmd.DoMenuItem acFormBar, acEditMenu, 10, , acMenuVer70

Exit_Search_Button_Click:
Exit Sub

Err_Search_Button_Click:
MsgBox Err.Description
Resume Exit_Search_Button_Click
End Sub
-------------------------------------------
 
Create a simple function to update the control:

Private Function SetDate()
If Not IsNull(Me.Control13) Then
Me.Control13 = Date()
End If
End Function

Then in the After Update property of each of the other twelve controls put a
call to the function:

=SetDate()

That is type the above directly into the After Update text box on the Events
tab of the properties dialog.
 
Create a simple function to update the control:

Private Function SetDate()
If Not IsNull(Me.Control13) Then
Me.Control13 = Date()
End If
End Function

Then in the After Update property of each of the other twelve controls put a
call to the function:

=SetDate()

That is type the above directly into the After Update text box on the Events
tab of the properties dialog.
--
Dave Hargis, Microsoft Access MVP



Goobz said:
Hey all...
First off, thanx for the help that you all tend to give from this
forum. I have captured a lot of good stuff, and for the 1st time, am
posting asking myself for your help... Here's what I have going on...
I have a form that has approx. 13 field in it. Fields 1-12 are user
inputable via Combo Boxes, or straight typing. Box 13 is locked, and I
would like to have it update when someone changes ***ANY*** of the
other 12 boxes. I **DO NOT** want to track simple record pull-ups...
I cleaned up the Events page, and here is the latest... The only thing
that is an [Event Procedure] is the current "search" button I have
embedded on the page... Please let me know what I need to change to
include the record save.
Private Sub Search_Button_Click()
On Error GoTo Err_Search_Button_Click
Screen.PreviousControl.SetFocus
DoCmd.DoMenuItem acFormBar, acEditMenu, 10, , acMenuVer70
Exit_Search_Button_Click:
Exit Sub
Err_Search_Button_Click:
MsgBox Err.Description
Resume Exit_Search_Button_Click
End Sub
-------------------------------------------- Hide quoted text -

- Show quoted text -

That worked fine in the field that I tested.. Thank you.. Here's what
I changed it to...
-------------------
Private Function SetDate()
If Not IsNull(Me.Comment) Then
Me.Updated = Date()
End If
End Function
-------------------

Now my question is, can I do a bunch of Else If's at all, instead of
duplicating this entire string, so it looks something like...

Private Function SetDate()
If Not IsNull(Me.Comment) Else
If Not IsNull(Me.DN) Else
If Not IsNull(Me.911_Zone) Then
Me.Updated = Date()
End If
End Function
 
That isn't necessary. If you do it like I suggested, the first control you
put a value or change a value in will populate the control. You only care if
it is Null, not the others. Once a value has been put in the control,
entering anything in the other controls will not affect it.
--
Dave Hargis, Microsoft Access MVP


Goobz said:
Create a simple function to update the control:

Private Function SetDate()
If Not IsNull(Me.Control13) Then
Me.Control13 = Date()
End If
End Function

Then in the After Update property of each of the other twelve controls put a
call to the function:

=SetDate()

That is type the above directly into the After Update text box on the Events
tab of the properties dialog.
--
Dave Hargis, Microsoft Access MVP



Goobz said:
Hey all...
First off, thanx for the help that you all tend to give from this
forum. I have captured a lot of good stuff, and for the 1st time, am
posting asking myself for your help... Here's what I have going on...
I have a form that has approx. 13 field in it. Fields 1-12 are user
inputable via Combo Boxes, or straight typing. Box 13 is locked, and I
would like to have it update when someone changes ***ANY*** of the
other 12 boxes. I **DO NOT** want to track simple record pull-ups...
I cleaned up the Events page, and here is the latest... The only thing
that is an [Event Procedure] is the current "search" button I have
embedded on the page... Please let me know what I need to change to
include the record save.
Private Sub Search_Button_Click()
On Error GoTo Err_Search_Button_Click
Screen.PreviousControl.SetFocus
DoCmd.DoMenuItem acFormBar, acEditMenu, 10, , acMenuVer70
Exit_Search_Button_Click:
Exit Sub
Err_Search_Button_Click:
MsgBox Err.Description
Resume Exit_Search_Button_Click
End Sub
-------------------------------------------- Hide quoted text -

- Show quoted text -

That worked fine in the field that I tested.. Thank you.. Here's what
I changed it to...
-------------------
Private Function SetDate()
If Not IsNull(Me.Comment) Then
Me.Updated = Date()
End If
End Function
-------------------

Now my question is, can I do a bunch of Else If's at all, instead of
duplicating this entire string, so it looks something like...

Private Function SetDate()
If Not IsNull(Me.Comment) Else
If Not IsNull(Me.DN) Else
If Not IsNull(Me.911_Zone) Then
Me.Updated = Date()
End If
End Function
 
Back
Top