PDA

View Full Version : Solved: Allow Authorisation On 2 Computers



Barryj
07-19-2011, 10:42 AM
I have the following code that allows a user to use a program on only one specific machine, it picks up the name of the machine.

I want to allow users to use another machine, I have tried putting in the other machines name but this does not work.

Can anyone offer a suggestion how to overcome this?

Private Sub Workbook_Open()

If Environ("ComputerName") <> UCase("Bal36840") Then
MsgBox "This Is Not An Authorised Computer, Contact The Administrator!" & vbCrLf & "(C)Barry 2011"
Me.Close SaveChanges:=False
Else
'** Do your thing here
MsgBox "You Have Authorisation To Use This Program On This Computer", , Format(Now, " dd mmm yyyy ") & ("ABC")

MsgBox "Please Ensure You Check The Fortnight Ending Date Before Printing TimeSheets", , Format(Now, " dd mmm yyyy ") & ("ABC")




End If
End Sub

I have tried changing this line:

If Environ("ComputerName") <> UCase("fuj36840", "fuj18369") Then

To

If Environ("ComputerName") <> UCase("Bal36840", "Bal18369") Then


Thanks for any ideas.

Kenneth Hobs
07-19-2011, 10:51 AM
If Left(UCase(Environ("ComputerName")),3) <> "BAL" Then

Barryj
07-19-2011, 11:04 AM
Kenneth, thanks for the reply, that is not working.

The 2 machines that I want to authorise names are in this line.



If Environ("ComputerName") <> UCase("Bal36840", "Bal18369") Then


When I put your line of code in it gave me the message box not an authorised computer as it should if it does not match the machine.

CatDaddy
07-19-2011, 11:08 AM
If Environ("ComputerName") <> UCase("Bal36840") And Environ("ComputerName") <> Ucase("Bal18369") Then

Barryj
07-19-2011, 11:15 AM
Thanks CatDaddy thats has done the trick, thanks also to Kenneth for your time, I will mark this as solved.

Thanks again.