ADO connection and database password

From: Paul M (anonymous_at_discussions.microsoft.com)
Date: 08/24/04


Date: Tue, 24 Aug 2004 06:19:18 -0700

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



Relevant Pages

  • Re: Queries
    ... Cannot execute a select query and the queries go in as unrelated ... Dim db As DAO.Database ... I am attempting to duplicate an Access database with VB6. ...
    (microsoft.public.vb.database)
  • Re: Checking multiple fields for Duplicate
    ... Dim stLinkCriteria As String ... Set rsc = Me.RecordsetClone ... purposely put in duplicate data, the code does not catch it. ...
    (microsoft.public.access.formscoding)
  • Re: One-to-Many???
    ... data into a real relational database, ... The data I will be gathering will be related to Location and Resource. ... I need to avoid duplicate entries of information. ... (e.g. John Smith = jsmith; Jane Smith = jsmith; Duplicate ID's so Jane Smith ...
    (microsoft.public.excel)
  • Re: Duplicate Data in Form, its Subform and SubSubForm
    ... Dim db As DAO.Database ... Dim rstT2A As DAO.Recordset 'tblControlSeccao ... Dim msg As String ... 'Make sure there is a record to duplicate. ...
    (microsoft.public.access.forms)
  • Re: Paste append error message
    ... I start wondering about my virus checker. ... to access 2003 and the duplicate button works fine. ... I plan to use the database at work on the network (we're still running ... I have to set this up on the network at work on Saturday ...
    (microsoft.public.access.gettingstarted)