Verify user

  • Thread starter Thread starter buzzandbeyond
  • Start date Start date
B

buzzandbeyond

Hi,

What I'm looking to do sounds simple in my head, but cant find out how
to execute it.

I dont want to use the security settings in Access, users moan about
another password, blah blah. So what I want to do is this.

Open the db
automatically get the user login using fosUserName()
Verify this exists in a table
if yes go to main page and timestamp table
if no, get warning error and exit.

any assistance is most welcome.

cheers
 
buzzandbeyond said:
Hi,

What I'm looking to do sounds simple in my head, but cant find out how
to execute it.

I dont want to use the security settings in Access, users moan about
another password, blah blah. So what I want to do is this.

Open the db
automatically get the user login using fosUserName()
Verify this exists in a table
if yes go to main page and timestamp table
if no, get warning error and exit.

any assistance is most welcome.

cheers

What have you done so far and what are you having problems with? Have you
gotten fosUserName() to work? Have you set up a table? All you need after
that is a simple DLookup() call to test if the current user exists in the
table...

If IsNull(DLookup("UserName", "TableName", "UserName = '" & fosUserName() &
"'")) = True Then
MsgBox "your warning"
DoCmd.Quit
Else...
 
Rick said:
What have you done so far and what are you having problems with? Have you
gotten fosUserName() to work? Have you set up a table? All you need after
that is a simple DLookup() call to test if the current user exists in the
table...

If IsNull(DLookup("UserName", "TableName", "UserName = '" & fosUserName() &
"'")) = True Then
MsgBox "your warning"
DoCmd.Quit
Else...

Hi Rick

At present anyone can access the db and run the reports, but not view /
edit the info. I am trying to stop everyone running the reports.

I've got the fosUserName() to work in the relevant queries. I have all
my tables setup including one titled tblOwner that contains the userid
(the field I need to check against).

I'm not sure where the best place to add the above script would be.

Does this make sense?

Dave
 
buzzandbeyond said:
At present anyone can access the db and run the reports, but not view
/ edit the info. I am trying to stop everyone running the reports.

I've got the fosUserName() to work in the relevant queries. I have
all my tables setup including one titled tblOwner that contains the
userid (the field I need to check against).

I'm not sure where the best place to add the above script would be.

Does this make sense?

You would need to run it in a code routine that executes when the app is
first opened. This could be a VBA function executed with the AutoExec macro
or it could be code in the Open or Load event of a form you have designated
to open in Startup properties.
 
You could also add security with a blank /same password for all users & use
a link to open the db
%programFiles%\Microsoft Office\Offfice\msaccess.exe <path to the db>
/wrkGrp<path to system db> /UID%USERNAME% /pwdsecret
this would require the username in the db to be the same as the windows
logon id (reccommended anyway)

Pieter
 
You could also add security with a blank /same password for all users & use
a link to open the db
%programFiles%\Microsoft Office\Offfice\msaccess.exe <path to the db>
/wrkGrp<path to system db> /UID%USERNAME% /pwdsecret
this would require the username in the db to be the same as the windows
logon id (reccommended anyway)

Pieter

Rick Brandt said:
You would need to run it in a code routine that executes when the app is
first opened. This could be a VBA function executed with the AutoExec
macro or it could be code in the Open or Load event of a form you have
designated to open in Startup properties.



--
 
Hi

I've got the following code:

********************
Private Sub Form_Open(Cancel As Integer)
If DLookup("[OwnerLogin]", "tblOwner", "[OwnerLogin] <> ' &
fOSUserName() & '") = True Then
MsgBox " Sorry " & fOSUserName() & ", You do not have access to
this database", vbExclamation, " Access Denied "
Else
MsgBox " Welcome, " & fOSUserName()
End If
End Sub
********************
but I cant get it to check the fOSUserName against the OwnerLogin in
the tblOwner.

I know this as I have removed my OwnerLogin and get the same message.

cheers
 
If DLookup("[OwnerLogin]", "tblOwner") <> fOSUserName() Then
or
If DLookup("[OwnerLogin]", "tblOwner") <> chr(34) & fOSUserName() & chr(34)
Then

(not sure if the chr(34) are needed or not)
 
Does tblOwner contain a single row, or multiple rows?

If it's single row only, Joan's solution should work.

If it's multiple rows, you need to replace

If DLookup("[OwnerLogin]", "tblOwner", "[OwnerLogin] <> ' &
fOSUserName() & '") = True Then

with

If DLookup("[OwnerLogin]", "tblOwner", "[OwnerLogin] <> '" &
fOSUserName() & "'") = True Then

Exagerated for clarity, that's

If DLookup("[OwnerLogin]", "tblOwner", "[OwnerLogin] <> ' " &
fOSUserName() & " ' ") = True Then
 
The tblOwner contains several different rows, these are the people I
want to access the system.

I've used Doug's example below, however it still does not pick up the
difference if the user is / isnt in the table.

What have i done wrong?
Does tblOwner contain a single row, or multiple rows?

If it's single row only, Joan's solution should work.

If it's multiple rows, you need to replace

If DLookup("[OwnerLogin]", "tblOwner", "[OwnerLogin] <> ' &
fOSUserName() & '") = True Then

with

If DLookup("[OwnerLogin]", "tblOwner", "[OwnerLogin] <> '" &
fOSUserName() & "'") = True Then

Exagerated for clarity, that's

If DLookup("[OwnerLogin]", "tblOwner", "[OwnerLogin] <> ' " &
fOSUserName() & " ' ") = True Then


--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


buzzandbeyond said:
Hi

I've got the following code:

********************
Private Sub Form_Open(Cancel As Integer)
If DLookup("[OwnerLogin]", "tblOwner", "[OwnerLogin] <> ' &
fOSUserName() & '") = True Then
MsgBox " Sorry " & fOSUserName() & ", You do not have access to
this database", vbExclamation, " Access Denied "
Else
MsgBox " Welcome, " & fOSUserName()
End If
End Sub
********************
but I cant get it to check the fOSUserName against the OwnerLogin in
the tblOwner.

I know this as I have removed my OwnerLogin and get the same message.

cheers
 
Sorry, I wasn't thinking.

If IsNull(DLookup("[OwnerLogin]", "tblOwner", "[OwnerLogin] <> '" &
fOSUserName() & "'")) = False Then


--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


buzzandbeyond said:
The tblOwner contains several different rows, these are the people I
want to access the system.

I've used Doug's example below, however it still does not pick up the
difference if the user is / isnt in the table.

What have i done wrong?
Does tblOwner contain a single row, or multiple rows?

If it's single row only, Joan's solution should work.

If it's multiple rows, you need to replace

If DLookup("[OwnerLogin]", "tblOwner", "[OwnerLogin] <> ' &
fOSUserName() & '") = True Then

with

If DLookup("[OwnerLogin]", "tblOwner", "[OwnerLogin] <> '" &
fOSUserName() & "'") = True Then

Exagerated for clarity, that's

If DLookup("[OwnerLogin]", "tblOwner", "[OwnerLogin] <> ' " &
fOSUserName() & " ' ") = True Then


--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


buzzandbeyond said:
Hi

I've got the following code:

********************
Private Sub Form_Open(Cancel As Integer)
If DLookup("[OwnerLogin]", "tblOwner", "[OwnerLogin] <> ' &
fOSUserName() & '") = True Then
MsgBox " Sorry " & fOSUserName() & ", You do not have access to
this database", vbExclamation, " Access Denied "
Else
MsgBox " Welcome, " & fOSUserName()
End If
End Sub
********************
but I cant get it to check the fOSUserName against the OwnerLogin in
the tblOwner.

I know this as I have removed my OwnerLogin and get the same message.

cheers
 
DOUG,

I BLODDY LOVE YOU, MAN.

cheers
Dave

Sorry, I wasn't thinking.

If IsNull(DLookup("[OwnerLogin]", "tblOwner", "[OwnerLogin] <> '" &
fOSUserName() & "'")) = False Then


--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


buzzandbeyond said:
The tblOwner contains several different rows, these are the people I
want to access the system.

I've used Doug's example below, however it still does not pick up the
difference if the user is / isnt in the table.

What have i done wrong?
Does tblOwner contain a single row, or multiple rows?

If it's single row only, Joan's solution should work.

If it's multiple rows, you need to replace

If DLookup("[OwnerLogin]", "tblOwner", "[OwnerLogin] <> ' &
fOSUserName() & '") = True Then

with

If DLookup("[OwnerLogin]", "tblOwner", "[OwnerLogin] <> '" &
fOSUserName() & "'") = True Then

Exagerated for clarity, that's

If DLookup("[OwnerLogin]", "tblOwner", "[OwnerLogin] <> ' " &
fOSUserName() & " ' ") = True Then


--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Hi

I've got the following code:

********************
Private Sub Form_Open(Cancel As Integer)
If DLookup("[OwnerLogin]", "tblOwner", "[OwnerLogin] <> ' &
fOSUserName() & '") = True Then
MsgBox " Sorry " & fOSUserName() & ", You do not have access to
this database", vbExclamation, " Access Denied "
Else
MsgBox " Welcome, " & fOSUserName()
End If
End Sub
********************
but I cant get it to check the fOSUserName against the OwnerLogin in
the tblOwner.

I know this as I have removed my OwnerLogin and get the same message.

cheers
 

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

Back
Top