Security level problems - duplicate data

B

Bob Richardson

I naively designed my DB with security level set to LOW, then went to
install the MDB on a computer that had the security level set to MEDIUM.

Some of the VBA code is totally ignored on the medium PC. For example:

' Look for multiple records with the same name
If DCount("*", "Contacts", "FirstName = " & Chr$(34) & _
Me.FirstName & Chr$(34) & " And LastName = " & _
Chr$(34) & Me.LastName & Chr$(34)) > 1 Then
MsgBox CStr(FirstName) & " " & CStr(LastName) & " is already in the
database. " _
& "Please make sure these are two different people. "
End If

I was trying to inform the user that she's just made a change to a record
that shares a name with at least one record. This worked beautifully on my
LOW security computer, but not on hers. What's the solution?

I suppose #1, I should make sure that my version of Access has the same
security level as hers. OK, I changed to MEDIUM, but of course the above
code is now ignore ignored on my computer too :( Is there a fix to this?
 
G

Graham R Seach

Bob,

Access won't be ignoring this code. Open the module in design view, select
that line and press F9. Then run the code and when it stops at that line,
press F8 to step through the code to see what's happening.

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
 
B

Bob Richardson

I purposely insert a duplicate record based on lastname and firstname, but
the primary key is an autonumber. Then I step through the code - I do that
lots to test the code - and VB does not detect the duplicate now. In other
words, at security level LOW it would trap the duplicates and print the
message, but at security level MEDIUM it doesn't. I didn't make any other
changes.

More importantly, I've now switched back to level LOW and it still doesn't
fid the duplicate.

Whether LOW (now!!!) or MEDIUM, when a duplicate is encountered, all edits
to the DB are ignored, and a blank record remains. If I change to a unique
name, then the edits are accepted.
 
B

Bob Richardson

I figured out my problem. I had reset the lastname/firstname key to unique.
Once I switched it back to allowing duplicate names, the error message
prints out, and the duplicate names are entered in the DB - that's what I
wanted.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top