473,382 Members | 1,545 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

ERROR: Object Required

103 100+
Please check the following code for adding records to a database:

Im getting the error:object required in the following code( which is in bold letters)

kindly go through
[vbcode]
Private Sub cmdAdd_Click()
strdep = cbodep.Text
rs.Open "select departmentno from Departments where departmentname ='" & strdep & "' ", conn, adOpenStatic, adLockOptimistic
If Not rs.EOF Then
strdep = rs!Departmentno
End If
rs.Close
strdes = cbodes.Text
rs.Open "select DesignationsId from Designations where DesignationName = '" & strdes & "' ", conn, adOpenStatic, adLockOptimistic
If Not rs.EOF Then
strdes = rs!designationsid
End If
rs.Close
If Trim(Form2.txtgid.Text) = "" Then
MsgBox "Please enter numbers", vbOKOnly, "ERROR"
cbostate.SetFocus
ElseIf IsNumeric(txtnme.Text) Then
MsgBox "Numbers are not allowed", vbExclamation, "ERROR"
txtnme.SetFocus
ElseIf cbosex.Text = "" Then
MsgBox "Enter the valid Data", vbExclamation, "ERROR"
cbosex.SetFocus
Else
rs1.Open "select * from EmployeeDetails where GTTLID = '" & Form2.txtgid.Text & "'", conn, adOpenStatic, adLockOptimistic

If rs1.EOF Then
conn.BeginTrans
conn.Execute "insert into EmployeeDetails(GTTLID,EmployeeName,age,sex,Depart ment,Designation,DOB,DOJ,PhoneNo,MobileNo,EmailId, Address) values ('" & txtgid & "','" & txtnme & "','" & cboage & "','" & cbosex & "'," & strdep & ",'" & strdes & "','" & dtdob & "','" & dtdoj & "','" & txtphne & "','" & txtmob & "','" & txtmail & "','" & txtadd & "')"
MsgBox "INSERTED NEW RECORDS", vbOKOnly, "ADDING NEW RECORDS"
Else
MsgBox "duplicate record"
End If
rs1.Close
Set rs1 = Nothing
End If
end sub
[/vbcode]


thanks in advance:
May 8 '08 #1
2 1781
lotus18
866 512MB
Please check the following code for adding records to a database:

Im getting the error:object required in the following code( which is in bold letters)

kindly go through
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdAdd_Click()
  2. strdep = cbodep.Text
  3.  rs.Open "select departmentno from Departments where departmentname ='" & strdep & "' ", conn, adOpenStatic, adLockOptimistic
  4. If Not rs.EOF Then
  5.  strdep = rs!Departmentno
  6. End If
  7.  rs.Close
  8.  strdes = cbodes.Text
  9.  rs.Open "select DesignationsId from Designations where DesignationName = '" & strdes & "' ", conn, adOpenStatic, adLockOptimistic
  10. If Not rs.EOF Then
  11.  strdes = rs!designationsid
  12. End If
  13. rs.Close
  14. If Trim(Form2.txtgid.Text) = "" Then
  15. MsgBox "Please enter numbers", vbOKOnly, "ERROR"
  16. cbostate.SetFocus
  17. ElseIf IsNumeric(txtnme.Text) Then
  18.    MsgBox "Numbers are not allowed", vbExclamation, "ERROR"
  19.    txtnme.SetFocus
  20. ElseIf cbosex.Text = "" Then
  21.    MsgBox "Enter the valid Data", vbExclamation, "ERROR"
  22.    cbosex.SetFocus
  23. Else
  24. rs1.Open "select * from EmployeeDetails where GTTLID = '" & Form2.txtgid.Text & "'", conn, adOpenStatic, adLockOptimistic
  25. If rs1.EOF Then
  26. conn.BeginTrans
  27.   conn.Execute "insert into EmployeeDetails(GTTLID,EmployeeName,age,sex,Department,Designation,DOB,DOJ,PhoneNo,MobileNo,EmailId,Address) values ('" & txtgid & "','" & txtnme & "','" & cboage & "','" & cbosex & "'," & strdep & ",'" & strdes & "','" & dtdob & "','" & dtdoj & "','" & txtphne & "','" & txtmob & "','" & txtmail & "','" & txtadd & "')"
  28. MsgBox "INSERTED NEW RECORDS", vbOKOnly, "ADDING NEW RECORDS"
  29.  Else
  30.   MsgBox "duplicate record"
  31.   End If
  32.  rs1.Close
  33.  Set rs1 = Nothing
  34.    End If
  35. end sub
  36.  
thanks in advance:
Enclosed your given codes with code tags for easy for us to understand.
Did you declared your rs1 as your new recordset? I cannot see your Active Connection or did I miss it?

Rey Sean
May 8 '08 #2
Vbbeginner07
103 100+
Enclosed your given codes with code tags for easy for us to understand.
Did you declared your rs1 as your new recordset? I cannot see your Active Connection or did I miss it?

Rey Sean


....yes i got it.....rs1 was not declared,,,,,,,,,,,,,,,,,

Active Connection............

Public conn As New ADODB.Connection
Public rs As New ADODB.Recordset
Public rs1 As New ADODB.Recordset

Public rsid As New ADODB.Recordset
Public rsnme As New ADODB.Recordset
Public rsdept As New ADODB.Recordset
Public rsdes As New ADODB.Recordset
Public Sub Main()
conn.Open "Provider=sqloledb.1;User ID=sa;password=;Data Source=STATISTICS;Initial Catalog=Nicks"
'conn.Open "Provider=sqloledb.1;User ID=sa;password=;Data Source=HS445;Initial Catalog=EXMP"
Form1.Show
End Sub


rs1 was declared now only.............

Nikhita(Nicks)
May 8 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Don Wash | last post by:
Hi All! I'm getting the following Error: No DLLs has been compiled yet and nothing in the \bin directory. So it is not the versioning problem or anything like that. And here are the...
0
by: muralidharan | last post by:
WebForm1.aspx Code: <%@ Register TagPrefix="ComponentArt" Namespace="ComponentArt.Web.UI" Assembly="ComponentArt.Web.UI" %> <ComponentArt:TreeView id="TreeView1" Height="520"...
9
by: Remulac | last post by:
Hello, I'm trying to get the value out of a dropdown list box and assign it to a variable. When I click on the list box, I invoke this line of code. I get the error, "Object reference not set...
3
by: Adriano | last post by:
Hello, when I try to print something, either DataGrid or from Crystal Report viever the folowing error message appears and cancels printing: Object reference not set to an instance of an...
8
by: ST | last post by:
Hello everyone, Can anyone help me with this error above when I debug my web app project in vstudio.net?? I can't figure it out! It was working fine for months, and now all of a sudden it's not!!...
0
by: HKSHK | last post by:
This list compares the error codes used in VB.NET 2003 with those used in VB6. Error Codes: ============ 3: This Error number is obsolete and no longer used. (Formerly: Return without GoSub)...
7
ak1dnar
by: ak1dnar | last post by:
Hi, I got this scripts from this URL There is Error when i submit the form. Line: 54 Error: 'document.getElementbyID(....)' is null or not an object What is this error. Complete Files
2
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
1
by: santoshsri | last post by:
Hi All, My C# web application calls a webservice to process a report. It sends XMLs as parameter and in response gets an XML node which stores Binay datatype bin.base64. It makes an instance of...
0
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.