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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Password update doesn't work - Module error

Status
Not open for further replies.

Thijs

Technical User
Nov 24, 2000
31
NL
Hi!

I've got the following problem. I have a form on which users can change their password. On this form there a submit button with the following code:

*********************
Private Sub cmdSubmit_Click()
Dim UpdatePW As New MyTestClass3

If Me.filledCheck = False Then
MsgBox "Please complete all entries before " & _
"submitting your new password.", vbInformation, _
"Warning"
ElseIf txtPassword <> txtConfirm Then
MsgBox &quot;Password and Confirm Password do not &quot; & _
&quot;match. Re-enter one or both.&quot;, vbInformation, _
&quot;Warning&quot;
Else
UpdatePW.NewPW txtEmpID, txtPassword

End If

End Sub
*********************

Then there is a module, MyTestClass3. The code is:

*********************
Sub NewPW(txtEmpID As String, txtPassword As String)
Dim cmd1 As Command
Dim strSQL As String

'Assign the command reference and connection.
Set cmd1 = New ADODB.Command
cmd1.ActiveConnection = CurrentProject.Connection

'Define the SQL string; notice
'the insertion of passed arguments.
strSQL = &quot;UPDATE gebruikers &quot; & _
&quot;SET gebruikers.password = &quot;&quot;&quot; & txtPassword & &quot;&quot;&quot; &quot; & _
&quot;WHERE user_id=&quot; & txtEmpID & &quot;;&quot;
Debug.Print strSQL

'Assign the SQL string to the command and run it.
cmd1.CommandText = strSQL
cmd1.CommandType = adCmdText
cmd1.Execute

'Confirmation message
MsgBox &quot;Your new password is accepted. &quot; & _
&quot;Return to Employee Authentication or &quot; & _
&quot;Exit this form.&quot;, vbInformation, _
&quot;Affirmative&quot;

End Sub
*********************

When I click on the submit button there comes a messagebox which says I didnt specify enough paramters :-S
I can't seem to figure out what is going wrong...can anyone help with this? I think it has to do with declaring txtEmpID as string, but I am not quite sure.

Thnx in advance,

Thijs Kromhout
 
Did you try:

call UpdatePW.NewPW(txtEmpID, txtPassword)

?



--------------------------------------
It's not the monsters under your bed, it is the men next door.
That make you fear, make you cry. Make you cry for the Child.
All the wars are fought amongst those lonely men. Unharmed, unscarred.
 
NVSbe (Programmer) Oct 24, 2002
Did you try:

call UpdatePW.NewPW(txtEmpID, txtPassword)?

I put it in the code. But the error still remains. The exact error is:

Run-time error '-2147217904 (80040e10)'
No value given for one or more required parameters.

Any other idea???




 
Just one:

make two strings (str1 and str2), fill them with the texts of our textfields and use those to call the sub

dim str1 as string, str2 as string
txtEmpID.setfocus
str1 = txtEmpID.text
txtPassword.setfocus
str2 = txtPassword.text

call UpdatePW.NewPW(str1, str2) --------------------------------------
It's not the monsters under your bed, it is the men next door.
That make you fear, make you cry. Make you cry for the Child.
All the wars are fought amongst those lonely men. Unharmed, unscarred.
 
I've tried but no luck :-(

The debugger still points to:
Call UpdatePW.NewPW(str1, str2)

And the error message still remains...

And I can't see what I am doing wrong...
 
Hmmm... come to think about it, the error might not be in the call, but in the sub itself.. Perhaps it just doesn't display that because it's in a module...

Try copying the code from the sub to the code window of your form, and call that sub instead of the one in the module, to see if it works... --------------------------------------
It's not the monsters under your bed, it is the men next door.
That make you fear, make you cry. Make you cry for the Child.
All the wars are fought amongst those lonely men. Unharmed, unscarred.
 
It still wont work :-(

He now keeps hanging on this peace of code:
************
ElseIf txtPassword <> txtConfirm Then
MsgBox &quot;Password and Confirm Password do not &quot; & _
&quot;match. Re-enter one or both.&quot;, vbInformation, _
&quot;Warning&quot;
*************

But why won't the module work...???


 
I have no idea why the module doesn't work, but for the msgbox to work, I think you need to assign the response to a variable...

dim ret as integer
ret = msgbox ( ... ) --------------------------------------
It's not the monsters under your bed, it is the men next door.
That make you fear, make you cry. Make you cry for the Child.
All the wars are fought amongst those lonely men. Unharmed, unscarred.
 
What the strangest thing is.
This module I got from another DB. Exported the module to my new db. Even the from I copy/pasted.

In the old DB it worked just fine.

Do you have to do something 'special' when you import a module/class???
 
Not according to my knowledge... Well, it might still be somewhere in the call of the module... My guess, because that's all I'm seeming to be doing here (
smiletiniest.gif
), would be for you to go into that other dvb, and see how it's called there...

Ehm.. Good luck, and lemme know if it worked... --------------------------------------
It's not the monsters under your bed, it is the men next door.
That make you fear, make you cry. Make you cry for the Child.
All the wars are fought amongst those lonely men. Unharmed, unscarred.
 
Well what I tried is the following.

I made some changes in the tables. In the old db employee ID was AutoNumber --> Long Integer. I reset that to Text.
And Access then gave the same error.

txtEmpID is no longer number but text. So is that where it is going wrong in the module? Somewhere lingers that when defining strings there is an important difference between ' and &quot;

Maybe this helps?
 
You know, i'm thinking that it's because your old db had a special reference...

I have code to change the current users password from a form if you'd like it...

--James

sub usrpwchng()

Dim wsp As Workspace
If Nz(txtNewPassword) <> Nz(txtVerifyPassword) Then
txtVerifyPassword.SetFocus
Beep
MsgBox &quot;Verify the new password by retyping it in the Verify box and clicking OK.&quot;, vbInformation
Exit Sub
End If
Set wsp = DBEngine.Workspaces(0)
On Error GoTo ErrorHandler
wsp.Users(CurrentUser).NewPassword Nz(txtOldPassword), Nz(txtNewPassword)
DoCmd.Close
'DoCmd.OpenForm &quot;Switchboard&quot;, , , stLinkCriteria
MsgBox &quot;Switchboard.&quot;
ErrorExit:
Set wsp = Nothing
Exit Sub
ErrorHandler:
If Err = 3033 Then
txtOldPassword.SetFocus
Beep
MsgBox &quot;The password you entered in the Old Password box is incorrect.&quot; _
& vbCrLf & vbCrLf _
& &quot;Please enter the correct password for this account.&quot;, _
vbInformation
Resume ErrorExit
End If
Err.Raise Err.Number



End sub junior1544@jmjpc.net
Life is change. To deny change is to deny life.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top