P
Paul M
Thanks in advance for any help that you might be able to
offer.
In a database I check for duplicate entries of
Organisation Name on a Form using the following code:
Private Sub OrganisationName_BeforeUpdate(Cancel As
Integer)
Dim cnn As New ADODB.Connection
Dim rst As New ADODB.Recordset
Dim Response As Integer
On Error GoTo ErrorHandler
If (Me![OrganisationName] <> Me!
[OrganisationName].OldValue) Or IsNull(Me!
[OrganisationName].OldValue) Then
cnn.Open CurrentProject.Connection
rst.Open "SELECT * FROM pritblOrganisation WHERE
[OrganisationName] = " & Chr(34) & Me!OrganisationName &
Chr(34), cnn, adOpenForwardOnly
If Not rst.EOF Then
Response = MsgBox("A Record Already Exists for
this Organisation!" & Chr$(10) & Chr$(13) & "Do You Want
to Cancel the Entry?", 20, "Duplicate Organisation Name")
If Response = vbYes Then
Me.Undo
End If
End If
rst.Close
cnn.Close
End If
GoTo Done
ErrorHandler:
MsgBox Err.Description
Done:
End Sub
This works great and prevents the users from entering a
duplicate organisation. However, when I password protect
the database with either share-level or user-level
security and uses the Form to check for entries I get an
Invalid Password or Invalid Username or Password message.
Now I know this is because I can't establish an ADO
connection without specifying the username and password.
So I put that in the cnn.Open line and great it works.
The real question is how do I get the administrator to
change the password without accessing and changing the
VBA of this form??
I am really stuck on this one and would really appreciate
any help at all.
Regards
Paul M
offer.
In a database I check for duplicate entries of
Organisation Name on a Form using the following code:
Private Sub OrganisationName_BeforeUpdate(Cancel As
Integer)
Dim cnn As New ADODB.Connection
Dim rst As New ADODB.Recordset
Dim Response As Integer
On Error GoTo ErrorHandler
If (Me![OrganisationName] <> Me!
[OrganisationName].OldValue) Or IsNull(Me!
[OrganisationName].OldValue) Then
cnn.Open CurrentProject.Connection
rst.Open "SELECT * FROM pritblOrganisation WHERE
[OrganisationName] = " & Chr(34) & Me!OrganisationName &
Chr(34), cnn, adOpenForwardOnly
If Not rst.EOF Then
Response = MsgBox("A Record Already Exists for
this Organisation!" & Chr$(10) & Chr$(13) & "Do You Want
to Cancel the Entry?", 20, "Duplicate Organisation Name")
If Response = vbYes Then
Me.Undo
End If
End If
rst.Close
cnn.Close
End If
GoTo Done
ErrorHandler:
MsgBox Err.Description
Done:
End Sub
This works great and prevents the users from entering a
duplicate organisation. However, when I password protect
the database with either share-level or user-level
security and uses the Form to check for entries I get an
Invalid Password or Invalid Username or Password message.
Now I know this is because I can't establish an ADO
connection without specifying the username and password.
So I put that in the cnn.Open line and great it works.
The real question is how do I get the administrator to
change the password without accessing and changing the
VBA of this form??
I am really stuck on this one and would really appreciate
any help at all.
Regards
Paul M