Re: How can I use SET programmically.



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 put
the
logging functionality into each of the forms. Remember that a form can be
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
of
the forms involved.

Yes, I realize that's a huge rework based on what you already seem to
have,
but I believe it'll be more reliable.

--
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 the
BeforeUpdate
event of each of the forms. I don't see an advantage to having all the
logic
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
be
True
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
create
a
function that will let me know when a user makes a change to the
data.
So
I
took an example from Microsoft, that uses 2 events the first is
the
onCurrent 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
I
write
that back into a HISTORY table.

This is my basic idea . . . . .does that help. Also here is the
code
that
I
am using . . . .

'*********************** onCurrent Event
***************************

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
BeforeUpdate
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
of
Control.
'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] =
frm.RecordSource
myRS![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
value
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
blank."
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
of
the
controls and what each value is. I am going to put them all in
an
array.
I
am trying to create a function to do this. How can sendThe name
of
my
"Main" form and Subform so I can SET then as object?This is what
I
am
thinking . . . . . . Dim frm1 as ObjectDim sfrm1 as ObjectDim
myForm,
mySubFormSet frm1 = myFormSet sfrm1 = frm1.mySubFormI know this
does
not
work but this is the normal syntax for this method.TIA,Rodger


















.



Relevant Pages