J
Julia B
Hi, I've got a continuous form and want a before update event on a field to
cancel depending on the value in another field. The problem I've got is that
whatever I try I can't get the value of the other field during the before
update event:
Here's my code:
Private Sub PNStored_BeforeUpdate(Cancel As Integer)
'if the part number's been changed, then make sure that the record can
be changed
Dim rs As Recordset
Set rs = Me.RecordsetClone
Dim strSearch As String
'I get the problem here - I get a runtime error 2108 you must save the field
first
Me.txtStoredRecordID.SetFocus
strSearch = str(Me.txtStoredRecordID.value)
rs.FindFirst "PartNumbers.RecordID = " & strSearch
Me.Bookmark = rs.Bookmark
If IsNull(rs![PartNumbersReceived.Status]) Then
currentRecdStatus = ""
Else
currentRecdStatus = rs![PartNumbersReceived.Status]
End If
currentStoredStatus = rs![PartNumbers.Status]
If currentRecdStatus <> "New" Then
MsgBox "You cannot change the part number as this is not a new
record!!", vbExclamation, "Error"
Cancel = True
Me.PNStored.SetFocus
ElseIf currentRecdStatus = "New" And currentStoredStatus = "Live" Then
MsgBox "You cannot change the part number as this is not a new
record!!", vbExclamation, "Error"
Cancel = True
Me.PNStored.SetFocus
Else
Me.DescStored.SetFocus
End If
End Sub
Thanks in advance.
Julia
cancel depending on the value in another field. The problem I've got is that
whatever I try I can't get the value of the other field during the before
update event:
Here's my code:
Private Sub PNStored_BeforeUpdate(Cancel As Integer)
'if the part number's been changed, then make sure that the record can
be changed
Dim rs As Recordset
Set rs = Me.RecordsetClone
Dim strSearch As String
'I get the problem here - I get a runtime error 2108 you must save the field
first
Me.txtStoredRecordID.SetFocus
strSearch = str(Me.txtStoredRecordID.value)
rs.FindFirst "PartNumbers.RecordID = " & strSearch
Me.Bookmark = rs.Bookmark
If IsNull(rs![PartNumbersReceived.Status]) Then
currentRecdStatus = ""
Else
currentRecdStatus = rs![PartNumbersReceived.Status]
End If
currentStoredStatus = rs![PartNumbers.Status]
If currentRecdStatus <> "New" Then
MsgBox "You cannot change the part number as this is not a new
record!!", vbExclamation, "Error"
Cancel = True
Me.PNStored.SetFocus
ElseIf currentRecdStatus = "New" And currentStoredStatus = "Live" Then
MsgBox "You cannot change the part number as this is not a new
record!!", vbExclamation, "Error"
Cancel = True
Me.PNStored.SetFocus
Else
Me.DescStored.SetFocus
End If
End Sub
Thanks in advance.
Julia