• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 432
  • Last Modified:

Run time error 424, object required

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
xpsavy
Asked:
xpsavy
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
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
 
[ fanpages ]IT Services ConsultantCommented:
...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
 
CWS (haripriya)Commented:
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
 
lalitgadaCommented:
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

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now