I have 2 fields that I have to make sure don't get screwed up.
(could be one it doesn't matter)
but what they want is no duplicates, warn the user
changing existing numbers is a no no. (of course they will have to
change errors so this is kinda WHAT ??)
the way it is set up is they put in an account number then a person id
number (which is text LOL)
ok if existing acount number then set it back to whatever and warn
them.
But I can't get all the checks to work at the same time, new record
can't equal old record in acount number or person id... BOTH are
unique.
so I keep fixing one way and another way doesn't work right.
are there any geniuses out there that can tell me what I need to
modify to catch existing value on entry as well as changing value to
existing values.
thanks big time for help I am just going in circles
Jerry
================================================== ==
so what I did was this on before update of the 2 fields...
trying acount number and it if passes going to person id then checking
and if it passes ok good record...If not setting back to whatever
Private Sub AcntNumber_BeforeUpdate(Cancel As Integer)
Cancel = ckContinue("AcntNumber")
End Sub
Private Sub PersonID_BeforeUpdate(Cancel As Integer)
Cancel = ckContinue("personid")
End Sub
================================================== ==
Public Function ckContinue(cname As String) As Boolean
Dim rst As Recordset
Dim str As String
Dim delim As String
If IsNull(Me.Controls(cname).Value) Then
MsgBox " You Must put in a valid AcntNumber to continue"
ActiveControl.Undo
DoCmd.RunCommand acCmdUndo
Else
str = Me.Controls(cname).Value
Set rst = CurrentDb.OpenRecordset(Me.RecordSource, dbOpenDynaset)
If rst.Fields(cname).Type = dbText Then
delim = """"
Else
delim = ""
End If
rst.FindFirst "[" & cname & "] = " & delim & str & delim
If Not rst.NoMatch Then
MsgBox "A record with AcntNumber = " & rst!AcntNumber & "
ID number = " & rst!idnum & " already exists"
ActiveControl.Undo
DoCmd.RunCommand acCmdUndo
Else
Exit Function
End If
rst.Close
End If
End Function