Re: How can I use SET programmically.
- From: "Douglas J. Steele" <NOSPAM_djsteele@xxxxxxxxxxxxxxxxx>
- Date: Tue, 16 Jan 2007 11:10:23 -0500
Others may disagree, but in my opinion, yes.
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
"Rodger" <NoSpam@xxxxxxxxxxx> wrote in message
news:%23ySs%23dYOHHA.992@xxxxxxxxxxxxxxxxxxxxxxx
But my forms are never and cannot be open without the main parent form.
So
should I still do this each form?
"Douglas J. Steele" <NOSPAM_djsteele@xxxxxxxxxxxxxxxxx> wrote in message
news:%231ZmHYYOHHA.2468@xxxxxxxxxxxxxxxxxxxxxxx
While I understand the desire to centralize, I think it's better to putthe
logging functionality into each of the forms. Remember that a form can beof
used by itself, or as a subform for more than one parent form.
My recommendation is that you put the code into the BeforeUpdate of each
the forms involved.have,
Yes, I realize that's a huge rework based on what you already seem to
but I believe it'll be more reliable.be
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
"Rodger" <NoSpam@xxxxxxxxxxx> wrote in message
news:umLl%23PYOHHA.3916@xxxxxxxxxxxxxxxxxxxxxxx
I am not sure what you mean. I want all my code in one place so I only
have
to make the change once. So should I use just the BeforeUpdate or the
onDirty? I guess I am not sure of the direction I need to take.
"Douglas J. Steele" <NOSPAM_djsteele@xxxxxxxxxxxxxxxxx> wrote in
message
news:Ow7IV$XOHHA.5000@xxxxxxxxxxxxxxxxxxxxxxx
I would think that all you'd need to do is put code in thelogic
BeforeUpdate
event of each of the forms. I don't see an advantage to having all the
in one place.
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
"Rodger" <NoSpam@xxxxxxxxxxx> wrote in message
news:eZBYR2XOHHA.3668@xxxxxxxxxxxxxxxxxxxxxxx
Doug,
So how would I use this with my current design, or would I have to
re-design
everything?
Thank you,
Rodger
"Douglas J. Steele" <NOSPAM_djsteele@xxxxxxxxxxxxxxxxx> wrote in
message
news:%23Yp8QeXOHHA.780@xxxxxxxxxxxxxxxxxxxxxxx
Assuming you're talking about bound forms, the Dirty property will
createTrue
when anything's changed on the form.
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
"Rodger" <NoSpam@xxxxxxxxxxx> wrote in message
news:%23WqnrGXOHHA.448@xxxxxxxxxxxxxxxxxxxxxxx
John/John,
Thank you Both for your reply. The reason I was doing this in an
array,
is
because I copied the code from Microsoft . . . :) I have been
trying
to
modify it on my own but have not been able to figure it out.
Here is my goal. I have a form with about 20 tabs on it and 19
of
those
tabs have at least one subform on them. I want to be able to
thea
data.function that will let me know when a user makes a change to the
So
I
took an example from Microsoft, that uses 2 events the first is
IonCurrent of the form, this looks at the form and then places all
the
values
of the form into an array, then on the BeforeUpdate I compare the
values
of
the current form to what is in the array and if there is a change
***************************write
thatthat back into a HISTORY table.
This is my basic idea . . . . .does that help. Also here is the
code
I
am using . . . .
'*********************** onCurrent Event
ofBeforeUpdate
Public Sub myCurrent(frm As Form)
ReDim myArray(frm.Controls.Count - 1)
X = -1
For Each C In frm.Controls
X = X + 1
Select Case C.ControlType
Case acTextBox, acComboBox, acListBox, acOptionGroup
'Skip
Updates field.
myArray(X) = C.Value
End Select
TryNextC:
Next C
End Sub
'***************************************************************
'********************** BeforeUpdate Event
**************************
'***************************************************************
'At the momment this is on the form and I call it from the
Event
Public Sub myHistory(frm As Form, myID, sfrm As SubForm)
Dim D As Control
Dim myDB, myRS, myNewRecord, myTable, myValue
Set myDB = CurrentDb()
Set myRS = myDB.openrecordset("HISTORY")
'Check each data entry control for change and record old value
frm.RecordSourceControl.
'Set the Array Counter
X = -1
For Each D In frm.Controls
' Only check data entry type controls.
X = X + 1
Select Case D.ControlType
Case acTextBox, acComboBox, acListBox, acOptionGroup
' Skip Updates field.
myValue = D.Value
'If D.Name = "Updates" Then GoTo TryNextD
If frm.NewRecord = True Then
myNewRecord = "New Record"
myRS.AddNew
myRS![HIS_USER] = useUserName
myRS![HIS_FIELD] = D.Name
myRS![HIS_FORM] = frm.Name
myRS![HIS_TABLE_ID] = myID
myRS![HIS_TABLE_NAME] =
ofvaluemyRS![HIS_OLD_VALUE] = "This is a new
record"
myRS![HIS_NEW_VALUE] = D.Value
myRS![HIS_DATE_CHANGE] = Date
myRS![HIS_TIME_CHANGE] = Time()
myRS.Update
GoTo TryNextD 'Exit Sub
End If
' If control was previously Null, record "previous
'*********************************************************************blank."was
blank."
If IsNull(myArray(X)) Then
myRS.AddNew
myRS![HIS_USER] = useUserName
myRS![HIS_FIELD] = D.Name
myRS![HIS_FORM] = frm.Name
myRS![HIS_TABLE_ID] = myID
myRS![HIS_TABLE_NAME] = frm.RecordSource
myRS![HIS_OLD_VALUE] = "Previous value was
myRS![HIS_NEW_VALUE] = D.Value
myRS![HIS_DATE_CHANGE] = Date
myRS![HIS_TIME_CHANGE] = Time()
myRS.Update
ElseIf myValue <> myArray(X) Then
myRS.AddNew
myRS![HIS_USER] = useUserName
myRS![HIS_FIELD] = D.Name
myRS![HIS_FORM] = frm.Name
myRS![HIS_TABLE_ID] = myID 'CHANGE THIS
myRS![HIS_TABLE_NAME] = frm.RecordSource
myRS![HIS_OLD_VALUE] = myArray(X)
myRS![HIS_NEW_VALUE] = D.Value
myRS![HIS_DATE_CHANGE] = Date
myRS![HIS_TIME_CHANGE] = Time()
myRS.Update
End If
End Select
TryNextD:
Next D
End Sub
"Rodger" <NoSpam@xxxxxxxxxxx> wrote in message
news:uxPAhoNOHHA.1872@xxxxxxxxxxxxxxxxxxxxxxx
All,I would like to be able to loop through a subform to get all
anthe
controls and what each value is. I am going to put them all in
ofarray.
I
am trying to create a function to do this. How can sendThe name
Imy
"Main" form and Subform so I can SET then as object?This is what
am
myForm,thinking . . . . . . Dim frm1 as ObjectDim sfrm1 as ObjectDim
notmySubFormSet frm1 = myFormSet sfrm1 = frm1.mySubFormI know this
does
work but this is the normal syntax for this method.TIA,Rodger
.
- Follow-Ups:
- Re: How can I use SET programmically.
- From: Rodger
- Re: How can I use SET programmically.
- References:
- How can I use SET programmically.
- From: Rodger
- Re: How can I use SET programmically.
- From: Rodger
- Re: How can I use SET programmically.
- From: Douglas J. Steele
- Re: How can I use SET programmically.
- From: Rodger
- Re: How can I use SET programmically.
- From: Douglas J. Steele
- Re: How can I use SET programmically.
- From: Rodger
- Re: How can I use SET programmically.
- From: Douglas J. Steele
- Re: How can I use SET programmically.
- From: Rodger
- How can I use SET programmically.
- Prev by Date: Re: how do I add another if statement to code
- Next by Date: Re: How can I use SET programmically.
- Previous by thread: Re: How can I use SET programmically.
- Next by thread: Re: How can I use SET programmically.
- Index(es):
Relevant Pages
|