473,387 Members | 1,578 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,387 software developers and data experts.

Error on Ado search

I have written this code to search my Database before adding a record but at the point (RsVehType.Find StrSql), it gives an error
Run-Time error '3001'
Arguements are of the wrong type, are out of acceptable range, or in conflict with one another
What is wrong please.
I have written the code below

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2. Me.Height = 3210
  3. Me.Width = 7710
  4. Set AdVehType = New ADODB.Connection
  5. AdVehType.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & App.Path & "\VEHICLE_TRACKER.mdb;"
  6. AdVehType.Open
  7. cmdControl(0).Enabled = True
  8. cmdControl(4).Enabled = True
  9. For i = 0 To 3
  10.     cmdNavigate(i).Enabled = False
  11. Next i
  12. End Sub
  13.  
  14. Private Sub cmdControl_Click(Index As Integer)
  15. Select Case Index
  16.     Case 0
  17.         Set RsVehType = AdVehType.Execute("SELECT txtVEHTYPE FROM tblVEHTYPE;")
  18.         StrSql = "txtVEHTYPE = '" & TxtType.Text & "';"
  19.         RsVehType.Find StrSql
  20.         If RsVehType.RecordCount = 0 Then
  21.             StrSql = "INSERT INTO tblVEHTYPE (txtVEHTYPE) VALUES ('" & TxtType.Text & "');"
  22.             AdVehType.Execute StrSql
  23.             TxtType = ""
  24.             TxtType.SetFocus
  25.         Else
  26.             MsgBox "This vehicle type already exist", vbInformation, "VEHICLE TRACKER"
  27.             TxtType.SetFocus
  28.         End If
  29.     Case 4
  30.         RsVehType.Close
  31.         AdVehType.Close
  32.         Set RsVehType = Nothing
  33.         Set AdVehType = Nothing
  34.         Unload Me
  35. End Select
  36. End Sub
  37.  
Dec 14 '06 #1
3 1760
sashi
1,754 Expert 1GB
I have written this code to search my Database before adding a record but at the point (RsVehType.Find StrSql), it gives an error
Run-Time error '3001'
Arguements are of the wrong type, are out of acceptable range, or in conflict with one another
What is wrong please.
I have written the code below

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2. Me.Height = 3210
  3. Me.Width = 7710
  4. Set AdVehType = New ADODB.Connection
  5. AdVehType.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & App.Path & "\VEHICLE_TRACKER.mdb;"
  6. AdVehType.Open
  7. cmdControl(0).Enabled = True
  8. cmdControl(4).Enabled = True
  9. For i = 0 To 3
  10.     cmdNavigate(i).Enabled = False
  11. Next i
  12. End Sub
  13.  
  14. Private Sub cmdControl_Click(Index As Integer)
  15. Select Case Index
  16.     Case 0
  17.         Set RsVehType = AdVehType.Execute("SELECT txtVEHTYPE FROM tblVEHTYPE;")
  18.         StrSql = "txtVEHTYPE = '" & TxtType.Text & "';"
  19.         RsVehType.Find StrSql
  20.         If RsVehType.RecordCount = 0 Then
  21.             StrSql = "INSERT INTO tblVEHTYPE (txtVEHTYPE) VALUES ('" & TxtType.Text & "');"
  22.             AdVehType.Execute StrSql
  23.             TxtType = ""
  24.             TxtType.SetFocus
  25.         Else
  26.             MsgBox "This vehicle type already exist", vbInformation, "VEHICLE TRACKER"
  27.             TxtType.SetFocus
  28.         End If
  29.     Case 4
  30.         RsVehType.Close
  31.         AdVehType.Close
  32.         Set RsVehType = Nothing
  33.         Set AdVehType = Nothing
  34.         Unload Me
  35. End Select
  36. End Sub
  37.  
Hi there,

The error message sound very logic & clear, it simply means that you are not passing enough arguments to the <.Find>. Run through your code once again. Kindly refer to below attached link for further reading & understand the usage of ADO find method. Good luck & Take care.

ADO : Find
Dec 15 '06 #2
RESOLVED


Thank you very much, I have resolved the problem by replacing

Expand|Select|Wrap|Line Numbers
  1. Set RsVehType = AdVehType.Execute("SELECT txtVEHTYPE FROM tblVEHTYPE;")
  2. StrSql = "txtVEHTYPE = '" & TxtType.Text & "';"
  3. RsVehType.Find StrSql
  4.  
to this:

Expand|Select|Wrap|Line Numbers
  1. Set RsVehType.Open "SELECT txtVEHTYPE FROM tblVEHTYPE WHERE txtVEHTYPE = '" & TxtType.Text & "';"
  2.  
Dec 15 '06 #3
sashi
1,754 Expert 1GB
RESOLVED


Thank you very much, I have resolved the problem by replacing

Expand|Select|Wrap|Line Numbers
  1. Set RsVehType = AdVehType.Execute("SELECT txtVEHTYPE FROM tblVEHTYPE;")
  2. StrSql = "txtVEHTYPE = '" & TxtType.Text & "';"
  3. RsVehType.Find StrSql
  4.  
to this:

Expand|Select|Wrap|Line Numbers
  1. Set RsVehType.Open "SELECT txtVEHTYPE FROM tblVEHTYPE WHERE txtVEHTYPE = '" & TxtType.Text & "';"
  2.  
Hi there,

Congrats on your discovery. Thanks for sharing the code / correction with us. Good luck & Take care.
Dec 16 '06 #4

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

Similar topics

4
by: David Moore | last post by:
Hello I am using the System.DirectoryServices namespace classes to access Active Directory. We connect using the LDAP://DOMAIN method. The code works on local dev boxes, and in staging, but...
6
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much...
6
by: blash | last post by:
Can someone help me? I really don't have a clue. My company staff told me they often got such error: "Object reference not set to an instance of an object." when they are in search result page...
2
by: david | last post by:
Problem: There is a search button, Search, in form, for searching patient info list. The error occurs after the following steps: 1. search first time is OK, and all found the records are...
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!!...
3
by: Doug Durrett | last post by:
I'm having an issue and wanted to pass it by everyone to see what you think. Here is my code. //Code Start searchs = new...
1
by: pbd22 | last post by:
hi. for some reason i am not able to navigate the dom. i keep getting the 'no properties' error but i think i am doing everything right. this is an XML response from an AJAX call. The ajax...
4
by: BenCoo | last post by:
Hello, In a Binary Search Tree I get the error : Object must be of type String if I run the form only with the "Dim bstLidnummer As New BinarySearchTree" it works fine. Thanks for any...
1
by: captainmorgan | last post by:
I have included an unbound field called which is used to quickly move to the desired record, by searching the last name field. I have been using this code for a few years, with only one...
2
by: vijayrvs | last post by:
SearchCrawler.java The program search crawler used to search the files from the website. From the following program i got 7 compiler error. can any body clarify it and provide me solution. ...
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$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.