A
alpharogue via AccessMonster.com
I wanted to know how I should translate these lines of VB to be compatible
with my Data Access Page. These lines are from my data entry form and are a
result from me converting the macros automatically through Access 2003. I
just needed to know what I should do behind controls on my DAP with this code
since it does not point correctly:
(What I am trying to do is auto-update fields when users edit existing
information or add a new record in the database as below.)
'------------------------------------------------------------
' CONTACT_BeforeUpdate
'
'------------------------------------------------------------
Private Sub CONTACT_BeforeUpdate(Cancel As Integer)
On Error GoTo CONTACT_BeforeUpdate_Err
' Adds a value to "Contact" field on update
Forms![CUSTOMER DATA]!CONTACT = CONTACT + 1
CONTACT_BeforeUpdate_Exit:
Exit Sub
CONTACT_BeforeUpdate_Err:
MsgBox Error$
Resume CONTACT_BeforeUpdate_Exit
End Sub
'------------------------------------------------------------
' LAST_TIME_MODIFIED_BeforeUpdate
'
'------------------------------------------------------------
Private Sub LAST_TIME_MODIFIED_BeforeUpdate(Cancel As Integer)
On Error GoTo LAST_TIME_MODIFIED_BeforeUpdate_Err
' Last time that record was modified
Forms![CUSTOMER DATA]![LAST TIME MODIFIED] = Time()
LAST_TIME_MODIFIED_BeforeUpdate_Exit:
Exit Sub
LAST_TIME_MODIFIED_BeforeUpdate_Err:
MsgBox Error$
Resume LAST_TIME_MODIFIED_BeforeUpdate_Exit
End Sub
'------------------------------------------------------------
' LAST_DATE_WORKED_BeforeUpdate
'
'------------------------------------------------------------
Private Sub LAST_DATE_WORKED_BeforeUpdate(Cancel As Integer)
On Error GoTo LAST_DATE_WORKED_BeforeUpdate_Err
' Last date that record was modified
Forms![CUSTOMER DATA]![LAST DATE WORKED] = DATE
LAST_DATE_WORKED_BeforeUpdate_Exit:
Exit Sub
LAST_DATE_WORKED_BeforeUpdate_Err:
MsgBox Error$
Resume LAST_DATE_WORKED_BeforeUpdate_Exit
End Sub
'------------------------------------------------------------
' Form_BeforeUpdate
'
'------------------------------------------------------------
Private Sub Form_BeforeUpdate(Cancel As Integer)
On Error GoTo Form_BeforeUpdate_Err
' Last date that record was modified
Forms![CUSTOMER DATA]![LAST DATE WORKED] = DATE
' Last time that record was modified
Forms![CUSTOMER DATA]![LAST TIME MODIFIED] = Time()
' Adds a value to "Contact" field on update
Forms![CUSTOMER DATA]!CONTACT = CONTACT + 1
Form_BeforeUpdate_Exit:
Exit Sub
Form_BeforeUpdate_Err:
MsgBox Error$
Resume Form_BeforeUpdate_Exit
End Sub
with my Data Access Page. These lines are from my data entry form and are a
result from me converting the macros automatically through Access 2003. I
just needed to know what I should do behind controls on my DAP with this code
since it does not point correctly:
(What I am trying to do is auto-update fields when users edit existing
information or add a new record in the database as below.)
'------------------------------------------------------------
' CONTACT_BeforeUpdate
'
'------------------------------------------------------------
Private Sub CONTACT_BeforeUpdate(Cancel As Integer)
On Error GoTo CONTACT_BeforeUpdate_Err
' Adds a value to "Contact" field on update
Forms![CUSTOMER DATA]!CONTACT = CONTACT + 1
CONTACT_BeforeUpdate_Exit:
Exit Sub
CONTACT_BeforeUpdate_Err:
MsgBox Error$
Resume CONTACT_BeforeUpdate_Exit
End Sub
'------------------------------------------------------------
' LAST_TIME_MODIFIED_BeforeUpdate
'
'------------------------------------------------------------
Private Sub LAST_TIME_MODIFIED_BeforeUpdate(Cancel As Integer)
On Error GoTo LAST_TIME_MODIFIED_BeforeUpdate_Err
' Last time that record was modified
Forms![CUSTOMER DATA]![LAST TIME MODIFIED] = Time()
LAST_TIME_MODIFIED_BeforeUpdate_Exit:
Exit Sub
LAST_TIME_MODIFIED_BeforeUpdate_Err:
MsgBox Error$
Resume LAST_TIME_MODIFIED_BeforeUpdate_Exit
End Sub
'------------------------------------------------------------
' LAST_DATE_WORKED_BeforeUpdate
'
'------------------------------------------------------------
Private Sub LAST_DATE_WORKED_BeforeUpdate(Cancel As Integer)
On Error GoTo LAST_DATE_WORKED_BeforeUpdate_Err
' Last date that record was modified
Forms![CUSTOMER DATA]![LAST DATE WORKED] = DATE
LAST_DATE_WORKED_BeforeUpdate_Exit:
Exit Sub
LAST_DATE_WORKED_BeforeUpdate_Err:
MsgBox Error$
Resume LAST_DATE_WORKED_BeforeUpdate_Exit
End Sub
'------------------------------------------------------------
' Form_BeforeUpdate
'
'------------------------------------------------------------
Private Sub Form_BeforeUpdate(Cancel As Integer)
On Error GoTo Form_BeforeUpdate_Err
' Last date that record was modified
Forms![CUSTOMER DATA]![LAST DATE WORKED] = DATE
' Last time that record was modified
Forms![CUSTOMER DATA]![LAST TIME MODIFIED] = Time()
' Adds a value to "Contact" field on update
Forms![CUSTOMER DATA]!CONTACT = CONTACT + 1
Form_BeforeUpdate_Exit:
Exit Sub
Form_BeforeUpdate_Err:
MsgBox Error$
Resume Form_BeforeUpdate_Exit
End Sub