Solved

Run time error 424, object required

Posted on 2006-06-15
4
412 Views
Last Modified: 2010-08-05
I am receving Run time Error 424 in this code
Private Sub cmdAdd_Click()
    txtPassword.Enabled = True
    txtCPassword.Enabled = True
 Open_conn
    Set rs = New ADODB.Recordset
        rs.Open "select * from login", conn, adOpenDynamic, adLockOptimistic
   
Dim samepassword As Boolean
   
    If txtPassword.Text = txtCPassword.Text Then
        samepassword = True
    Else
        samepassword = False
        MsgBox "The passwords do not match", , "Login"
        txtCPassword.SetFocus
        Exit Sub
    End If
    rs.MoveLast
    rs.AddNew
    rs.Fields("userid") = Trim(txtUserName.Text)       <------------ERROR Place
    rs.Fields("pwd") = Trim(txtPassword.Text)
    rs.Fields("cpwd") = Trim(txtCPassword.Text)
    rs.Update
   
    MsgBox "Username and password added"
    txtUserName.Text = ""
    txtPassword.Text = ""
    txtCPassword.Text = ""
    txtUserName.SetFocus
Close_conn
End Sub
0
Comment
Question by:xpsavy
4 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 250 total points
ID: 16911382
what are the fields of the login table?


    rs.Fields("userid").Value = Trim(txtUserName.Text)       <------------ERROR Place
    rs.Fields("pwd").Value = Trim(txtPassword.Text)
    rs.Fields("cpwd").Value = Trim(txtCPassword.Text)
0
 
LVL 35

Expert Comment

by:[ fanpages ]
ID: 16916883
...Is the maximum length (in characters) of the "userid" column in the [login] table being exceeded by the character length of the text in txtUserName.Text?

Is "UserId" a text (string) field in the table?  Or is it a numeric (long?) data type?

Thanks for your clarification.

BFN,

fp.
0
 
LVL 16

Expert Comment

by:CWS (haripriya)
ID: 16918029
It should be one of these two.

Either the table doesnot contain the field "userid", or the form doesnot contain the control "txtUserName".

Check if both are spelled correctly.

Otherwise, give rs("userid") instead of rs.fields("userid")
0
 
LVL 1

Expert Comment

by:lalitgada
ID: 16974966
Check out for the field name userid. whether the field name you are using is correct or not and also check the text box name of txtUserName whether it is te same as that given during desidn time.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now