A
Anita
I'm running into run-time error 3164, field can not be updated, when I try to
pass a value to a field. This field, "Event ID," exists in the query my form
is based on, but is not a visible control on the form.
Private Sub EventDate_BeforeUpdate(Cancel As Integer)
'Created November 2006 - currently in testing
'If user attempts to change the date of the Last Updated event, this sub
creates a _
new Event record and plugs the just-inputted data into it. This prevents
user from _
incorrectly overriding Last Updated data for all existing records tied to
the current _
Last Updated Event record.
Dim intNewEventDate As Date
Dim intNewEventID As Integer
Dim conEvent As Connection
Dim rstEvent As Recordset
intNewEventDate = Me.EventDate
Cancel = True
Set conEvent = CurrentProject.Connection
Set rstEvent = New Recordset
With rstEvent
.Source = "Select * from Event"
.ActiveConnection = conEvent
.LockType = adLockOptimistic
.Open
.AddNew
![Event Type] = "Last Updated"
![EventDate] = intNewEventDate
intNewEventID = ![Event ID].Value
.MoveFirst
End With
rstEvent.Close
Set rstEvent = Nothing
conEvent.Close
Set conEvent = Nothing
Me.[Event ID].Value = intNewEventID ******Run-time error 3164**********
Me.Requery
pass a value to a field. This field, "Event ID," exists in the query my form
is based on, but is not a visible control on the form.
Private Sub EventDate_BeforeUpdate(Cancel As Integer)
'Created November 2006 - currently in testing
'If user attempts to change the date of the Last Updated event, this sub
creates a _
new Event record and plugs the just-inputted data into it. This prevents
user from _
incorrectly overriding Last Updated data for all existing records tied to
the current _
Last Updated Event record.
Dim intNewEventDate As Date
Dim intNewEventID As Integer
Dim conEvent As Connection
Dim rstEvent As Recordset
intNewEventDate = Me.EventDate
Cancel = True
Set conEvent = CurrentProject.Connection
Set rstEvent = New Recordset
With rstEvent
.Source = "Select * from Event"
.ActiveConnection = conEvent
.LockType = adLockOptimistic
.Open
.AddNew
![Event Type] = "Last Updated"
![EventDate] = intNewEventDate
intNewEventID = ![Event ID].Value
.MoveFirst
End With
rstEvent.Close
Set rstEvent = Nothing
conEvent.Close
Set conEvent = Nothing
Me.[Event ID].Value = intNewEventID ******Run-time error 3164**********
Me.Requery