T
tecman
Hello All,
I am trying in a form using visual basic to search for a new userid
(created by concatenating the first letter of the first name and last
4 of the last name +1). I want to be able to search the userid [UID]
field in the table for duplicates. here is some of my code so far. the
*(added for reference) line gives the error "Run time error 2001",
"You have canceled the previous operation" If you have a user named
Bob Tester, the userid will return BTEST1. I will eventually modify
the code to add 1 to the end if the userid already exists. Thanks in
advance for your help.
Private Sub Command6_Click()
Dim UIDNEW As String
Dim fname As String
Dim lname As String
Dim D As Integer
D = 1
fname = Me.first
lname = Me.last
UIDNEW = Mid(fname, 1, 1) & Mid(lname, 1, 4) & D
* If Not IsNull(DLookup("[UID]", "Table1", "UID=" & UIDNEW)) Then
MsgBox "This Key already exists"
Else
Me.uidbox = UIDNEW
Me.uidbox.Requery
End If
End Sub
I am trying in a form using visual basic to search for a new userid
(created by concatenating the first letter of the first name and last
4 of the last name +1). I want to be able to search the userid [UID]
field in the table for duplicates. here is some of my code so far. the
*(added for reference) line gives the error "Run time error 2001",
"You have canceled the previous operation" If you have a user named
Bob Tester, the userid will return BTEST1. I will eventually modify
the code to add 1 to the end if the userid already exists. Thanks in
advance for your help.
Private Sub Command6_Click()
Dim UIDNEW As String
Dim fname As String
Dim lname As String
Dim D As Integer
D = 1
fname = Me.first
lname = Me.last
UIDNEW = Mid(fname, 1, 1) & Mid(lname, 1, 4) & D
* If Not IsNull(DLookup("[UID]", "Table1", "UID=" & UIDNEW)) Then
MsgBox "This Key already exists"
Else
Me.uidbox = UIDNEW
Me.uidbox.Requery
End If
End Sub