Solved

Run time error 424, object required

Posted on 2006-06-15
4
416 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 143

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Windows 10 start screen issues 9 61
VB6 Compile Compatibility Issue 4 122
How does CurrentUser work? 10 42
VBA - If Bookmark = "XXBOOKMARKXX" then 15 51
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

733 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