Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Password that is Date Sensitive? 2

Status
Not open for further replies.

BillMc

Programmer
Dec 8, 2000
45
US
In addition to securing my database with a password, I need the user to enter a password (let's say each month) in order to gain access to the application. I will be billing my customer's each month for the application. If they do not pay, I must have the ability to shut down the application. Any suggestions??? Thanks, Bill
 
is this one customer, or multiple customers?
if multiple, do you mean to give ALL customers the same password if they pay up?
if multiple, do you have a way to know which customer is logging on?
a different 'good' password for each new paid-up month?

g
 
G,
There are muliple customers, however, using the same password for all customers will be OK. I am not concerned about one customer passing around the monthly password.
Yes, there would need to be a new 'good' password for each new paid-up month. Thanks for responding, Bill
 
That's called a firebrick.

I'd suggest declaring a variable blnPaidInFull.

On the first of each month, the value becomes FALSE and the user is prompted to enter their unique string. I'd suggest that you multiply the date by your customer's unique ID number (I assume you have an Access table to track their payments). You could use other characters as well to make sure no one calculates the value on their own.

Create a Public Function: "FireBrick" that opens a Pop Up, Modal form asking the user to input the most recent passcode. If they enter the wrong passcode, close the program.

On the Form's Load, Activate and AfterUpdate run the "FireBrick" function:
Code:
If blnPaidInFull = False Then
FireBrick
Else
(the normal event)

Preface any number of events with the function in case they don't shut down.

Depending on how unscrupulous your customers are, they could change the system time and date. You'll want to track the current date (CurDate) as well as yesterday's date (YestDate):

Code:
If YestDate() > Date() Then
MsgBox "Hey, your system clock is wrong.  Reset it to continue."
DoCmd.RunCommand.acClose
Else
YestDate() = CurDate()
CurDate() = Date()
End If

I'm sure there are much more elegant ways to accomplish this, but I hope this helps.

 
Sounds like that will work. I will work on the details. Thanks for your help. Bill
 
On a different track, you may want to consider the interval of "1 Month". I would find this somewhat burdensome. If your service is useful and priced within reason (the old cost benefit ratio thing), your customers would probably pay at least semi-anually. You could set up a process to remind them to pay from YOUR system, send an e-mail somretime before the liscensine expriation (one month?) and again a few days before expiration.


MichaelRed
m.red@att.net

There is never time to do it right but there is always time to do it over
 
Michael,
Thanks for your response. I really need to do this on a month to month basis. My competition billed in this manner and the customer's do like it. I won't mind the cash flow either!
If you can help me with the nuts and bolts of accomplishing this, it would greatly appreciated. I am an Access developer NOT A PROGRAMMER and I get lost with explainations that refer to code.
I can get help from a professional programmer,however, I have been able to build this application on my own and like the fact that I can make it do what I want to. It really does work well.
Once again, if you can give me a step by step approach, I should be able to work this out.
I am getting really anxious as I have sold the application to several companies but I just can't realease it until the billing is in place.

Thanks, Bill
 
ok piggybacking on BoxHead with step-by-step instructions:

create a table with one field, a text field called CurrentPassword. table name = tblPAID.


make a little pop-up form that's called frmPASSWORD. base it on tblPAID.

with:
Label: 'ENTER PASSWORD:'
Text box: called txtPassword with input mask = password (will be ******* when they type)
Button btnCheckPassword with caption OK and don't use the Wizard
Text Box (visible=no) control source = CurrentPassword.

for the button OnClick event, choose Event Procedure
(i've chosen at random the formula. you can do what you want, and for every month you will calculate and distribute this password as people pay up). Since when the month changes the formula will change, it will no longer match the CurrentPassword and the pop-up frmPassword will come up until they put in the correct password:

type this in between the Sub() and EndSub() lines:

Code:
Private Sub btnCheckPassword_Click()
	if forms!Password!txtPassword = (15564 * month(date())) + 211 then
	              me.CurrentPassword = me.Password
     	               docmd.openForm "MainScreen"
	else
     		msgbox "Sorry this is wrong Please try again"
     		me.txtPassword.setfocus  'will put the focus in the txtPassword box so they can try again
	end if
End Sub()

then, so they only have to do this once per month, instead of every day so they won't be irritated, we'll check to see if they have already entered the correct password for the month. BoxHead said to declare a variable and set it to no on the first of the month, maybe boxhead you can elaborate cause i dont really get it cause i dont see how the variable can exist after the program is closed. i dont know much about that stuff. here's what i (hack job?) would do:

in the form frmPassword OnOpen event, put this:

Code:
if me.currentpassword = (15564 * month(date())) + 211 then
	              docmd.closeform "frmPassword"
		docmd.openForm "MainScreen"
	end if

But yes BoxHead is right: unscrupulous people can do all sorts of things if they know enough, re: changing system date/time.....

also like BoxHead i'm sure there are more elegant ways of doing this, but hope this gets you thinking....
 
Thanks for taking the time to walk me through this. I am sure I can do this now. You and BoxHead have been very helpful and very generous with your time and knowledge. Thanks again. Bill
 
G,
I have created the table and form as you described and endered the code in VB. Your code worked fine. Visual Basic changed a few things: eg: [tt](15564 * month(date()))[/tt] was changed to [tt](15564 * month(date))[/tt]

Problem: When I open the form I am getting a compile error message: When I press OK it highlights [tt]Docmd.closeform[/tt]

The name of my form is "frmPassword" and I have double checked the spelling. Any suggestions?

I have several questions:
Should the lack of a password cause this form to open automatically or should I activate it with AutoExec?

The password for the month? In your example (15564 * month(date()))) + 211... What is the Date? Is it the 1st of the month? What is the password to enter?

Thanks, Bill

 
G,
in the form frmPassword OnOpen event I selected [Event procedure] and the VB Code looks like this:

Private Sub Form_Open(Cancel As Integer)
If Me.CurrentPassword = (15564 * Month(Date)) + 211 Then
DoCmd.closeform "frmPassword"
DoCmd.OpenForm "MainScreen"
End If
End Sub



Do you see the error?
Thanks, Bill
 
G,
In your instructions you told me to enter the following:

[tt]Private Sub btnCheckPassword_Click()
if forms!Password!txtPassword = ....[/tt]

I believe it should be:
[tt]Priate Sub btnCheckPassword_Click()
if forms!frmPassword!txtPassword = ....[/tt]

Am I correct? Thanks, Bill
 
Use the docmd as follows:
DoCmd.Close acForm, "formName"

mike

 
Bill,

You also need to move your code to the change event or afterupdate event of the field the password is entered in and not on the open event of the password form.

Mike
 
Mike,
I removed the [event procedure] from the form event on open and placed the following:

[tt]Private Sub txtpassword_AfterUpdate()
If Me.CurrentPassword = (15564 * Month(Date)) + 211 Then
DoCmd.Close acForm, "formName"
DoCmd.OpenForm "MainScreen"
End If
End Sub[/tt]

in the [Event Procedure] after update in the txtPassword
text box.

after entering a number the focus moves to the "OK" command button. the [Event Procedure} is as follows:

[tt]Private Sub btnCheckPassword_Click()
If Forms!frmPassword!txtpassword = (15564 * Month(Date)) + 211 Then
Me.CurrentPassword = Me.txtpassword
DoCmd.OpenForm "MainScreen"
Else
MsgBox "Sorry this is wrong. Please try again."
Me.txtpassword.SetFocus 'will put the focus in the txtPassword box so they can try again
End If

End Sub[/tt]

Because I input a wrong number I am receiving the message:
"Sorry this is wrong. Please Try again."

So that's good. I now need to put in a correct number.

I do not understand how this number is calculated (as I mentioned earlier). What is the correct entry?

It appears as though I am headed in the right direction, however, I'm not there yet.

Thanks for your help,
Bill
bill@bmcauley.com
 
? Month(Date) returns the ordinal number of the current month. Any "date" in the month of September would return "9".

Date is an intrinsic functions. It returns the current date, such as

? Date
9/8/01

With the settings for the date format.

MichaelRed
m.red@att.net

There is never time to do it right but there is always time to do it over
 
Mike,
Thanks. Now I understand how the password is determined each month. Bill
 
Bill,
I apologize to you an Ginger for not carefully checking all of the threads when I responded to the issue on the Close method. It appears from what Ginger had you doing you can just change the syntax in the open form event from

docmd.closeform "frmPassword"

'to -- this line is not included in the code.

docmd.close acform, "frmPassword"

this should do what she was suggesting in the first place which is an excellent idea.

Mike
michaelj1@home.com
 
Mike,
Thanks for the clarification. I made the change. It looks as follows:

[tt]Private Sub Form_Open(Cancel As Integer)
If Me.CurrentPassword = (24 * Month(Date)) + 99 Then
DoCmd.Close acForm, "frmPassword"
DoCmd.OpenForm "MainScreen"
End If
End Sub
[/tt]

The button event procedure is:

[tt]Private Sub btnCheckPassword_Click()
If Forms!frmPassword!txtpassword = ((24 * Month(Date)) + 99) Then
Me.CurrentPassword = Me.txtpassword
DoCmd.OpenForm "MainScreen"
Else
MsgBox "Sorry password is incorrect. Please try again."
Me.txtpassword.SetFocus 'will put the focus in the txtPassword box so they can try again
End If
End Sub
[/tt]

The result of the date formula (24 x 9 + 99) is 315.

I have entered 315 as the password and pressed "OK". However, I'm getting the message box "Sorry password....

I am not getting any error messages as far as the code is concerned. It should work??? Do you see something wrong?

Bill


 
Bill,
Try changing the field in the table to a data type of number. You may need to change the txtPassword text box format to fixed and a 0 decimal places value for looks.

Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top