Solved

Run time error 424, object required

Posted on 2006-06-15
4
414 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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

810 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