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

why did it stop working? 2

Status
Not open for further replies.

chaosguy

Programmer
Joined
Nov 5, 2005
Messages
45
Location
VC
I have no idea what happened, but my change password form just stopped working. The code below is used on the cmdChange_password button. It get an error in the second line everything I try to change the password saying
"Compiler error, user-defined type not defined."
It worked when I just wrote the code, but not it's not working, lol. Can anyone help, I mean do anyone know why?

Here's the code

Private Sub ChangePass_Click()
Dim ThisDB As DAO.Database ---------> error in this line here.
Dim rstPassword As DAO.Recordset

If IsNull(Me.CurrentPass.Value) Then
MsgBox "You must enter the current password before changing.", vbExclamation, "Password Not Changed."
ElseIf IsNull(Me.NewPass.Value) Then
MsgBox "You must enter a password before saving changes.", vbExclamation, "Password Not Changed."
ElseIf Me.CurrentPass.Value <> DLookup("Password", "tblPassword") Then
MsgBox "The current password you have entered is incorrect.", vbExclamation, "Password Not Changed."
ElseIf Me.NewPass.Value <> Me.CurrentPasscheck.Value Then
MsgBox "The passwords you have entered do not match!", vbExclamation, "Password Not Changed."
Else
Set ThisDB = CurrentDb()
Set rstPassword = ThisDB.OpenRecordset("tblPassword", dbOpenDynaset)

ThisDB.Execute "DELETE * FROM tblPassword;", dbFailOnError 'Clear table to ensure only one password

With rstPassword
.AddNew
!Password = Me.NewPass.Value
.Update
End With

rstPassword.Close
ThisDB.Close
Set rstPassword = Nothing
Set ThisDB = Nothing
MsgBox "Your Password have been changed"
DoCmd.Close
End If
End Sub

Chaosguy - To die would be an awefully big adventure.
 
Check your References when you have the code in view. You may have issues with that and make sure DAO is checked.

Gary
gwinn7
 
say what? :s "I'm confused"

Chaosguy - To die would be an awefully big adventure.
 
When in VBE, menu Tools -> References ...
Check that the Microsoft DAO 3.x library is ticked.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
What gwinn7 is suggesting is that in the VBA code view (where you write code) select TOOLS-->REFERENCES and make sure that Microsoft DAO Object Library is checked.
 
Chaosguy,
Think of a reference as a door to a tool room. Once you open the door you can use the tools within the room. In side each tool room is a related group of objects and methods. For example if you wanted to work with Excel objects you make a reference to Excel. DAO is a group of objects designed to work with the data in data bases. ADODB is another group.
If you do not have the reference established ("the door is open") when you do this:

dim rstPassword as dao.recordset

VB does not know where to go to find a dao.recordset object. It goes through each open door ("reference") looking for a dao.recordset, but never finds one so it thinks that you are trying to define your own.
Hence you get the user defined type error.
 
Oh, well thanks guys, big help, big help. Gwinn thanks very much and I gaved ya a star. Also gaved PHV a star for breakign it down for a cad like myself :$. Anyways thanks and it works fine now. I don't know how it got unticked tho cause it was working fine at first. Oh well works now so that's all that matters. Thank you so much guys.

Chaosguy - To die would be an awefully big adventure.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top