473,396 Members | 2,039 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,396 software developers and data experts.

Search error

Ali Rizwan
925 512MB
hi all,
I m using this code for searching with respect to Reg No:

Expand|Select|Wrap|Line Numbers
  1. ADODC1.Recordset.Find "Reg No = " & txtREG
  2.  
But it is not searching
Thanx
Oct 2 '07 #1
25 1864
jrtox
89
hi all,
I m using this code for searching with respect to Reg No:

Expand|Select|Wrap|Line Numbers
  1. ADODC1.Recordset.Find "Reg No = " & txtREG
  2.  
But it is not searching
Thanx
Try This One:

Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "SELECT * FROM TableName WHERE FieldName='" & txtREG.Text & "'"
adodc1.refresh

Regards
ervin
Oct 2 '07 #2
Ali Rizwan
925 512MB
Try This One:

Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "SELECT * FROM TableName WHERE FieldName='" & txtREG.Text & "'"
adodc1.refresh

Regards
ervin
Thanxxxxxxxxxxxxxxxx Ervin
And this Thanx for answering my all questions at time.
Oct 2 '07 #3
Ali Rizwan
925 512MB
Try This One:

Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "SELECT * FROM TableName WHERE FieldName='" & txtREG.Text & "'"
adodc1.refresh

Regards
ervin
Hello Ervin,
This code is doing nothing.
I have a database named Information
Table Name is Info
And i have to search about Name and Reg No both.
Please solve the problem
Thanx
Oct 3 '07 #4
hariharanmca
1,977 1GB
Hello Ervin,
This code is doing nothing.
I......Thanx
Try the below code.
Expand|Select|Wrap|Line Numbers
  1.     Adodc1.CommandType = adCmdUnknown
  2.     Adodc1.RecordSource = "SELECT * FROM TableName WHERE strFieldName Like '" & txtREG.Text & "' or numberFieldName = " & val(txtREG.Text)
  3.     Adodc1.Refresh
  4.     Adodc1.Recordset.MoveFirst
  5.     MsgBox " No. Record : " & Adodc1.Recordset.RecordCount
Oct 3 '07 #5
Killer42
8,435 Expert 8TB
I wouldn't bother with the Val() function, since you're placing it into a string anyway.
Oct 3 '07 #6
hariharanmca
1,977 1GB
That's sample for number field and string field (he is not clear with where clause). Not exactly to the search value..

The sample like below.

Expand|Select|Wrap|Line Numbers
  1.  Adodc1.RecordSource = "SELECT * FROM TableName WHERE strFieldName Like '" & txtStringValue.Text & "' or numberFieldName = " & val(txtNumericValue.Text)
Oct 3 '07 #7
Ali Rizwan
925 512MB
Thanks all of you for helping me a lot.
Thans again.
Oct 3 '07 #8
Ali Rizwan
925 512MB
Try the below code.
Expand|Select|Wrap|Line Numbers
  1.     Adodc1.CommandType = adCmdUnknown
  2.     Adodc1.RecordSource = "SELECT * FROM TableName WHERE strFieldName Like '" & txtREG.Text & "' or numberFieldName = " & val(txtREG.Text)
  3.     Adodc1.Refresh
  4.     Adodc1.Recordset.MoveFirst
  5.     MsgBox " No. Record : " & Adodc1.Recordset.RecordCount
Hello hari,
This code works but the problem is that after searching the record we can only see the searched record in the grid.
I want to see other records too.
Thanx
Oct 3 '07 #9
hariharanmca
1,977 1GB
Hello hari,
This code works but the problem is that after searching the record we can only see the searched record in the grid.
I want to see other records too.
Thanx
You want to search like

If you type 'A' then the recordset should select name starts with 'A'?
Can you explain properly?
Oct 3 '07 #10
Ali Rizwan
925 512MB
You want to search like

If you type 'A' then the recordset should select name starts with 'A'?
Can you explain properly?
Yeah this one and this too

Suppose i have following records in name field
ABC
ABD
BCD
BBG
XYZ

Now using your code i select ABC to search
Now the DataGrid only shows the record ABC but not ABD,BCD,BBG.XYZ
I want to show all of records.

Thanx
Oct 3 '07 #11
hariharanmca
1,977 1GB
Yeah this one and this too
................
Purpose of where clause is to select particular record then why you want to display all records?
Oct 3 '07 #12
Ali Rizwan
925 512MB
You want to search like

If you type 'A' then the recordset should select name starts with 'A'?
Can you explain properly?
Hello Hari,
One more problem occuring.
When i enter a Field name with a space then it show an error and does not search.
I have search for field Reg No it does not search.
Thanks
Oct 3 '07 #13
Ali Rizwan
925 512MB
Purpose of where clause is to select particular record then why you want to display all records?
I have labels too connected with same database which show only one record at a time.
When i search the required record shows in labels but i dont want to do the same thing to DGrid. i want to show all records here. But the required record will focused automatically when i searched.
Thanx
Oct 3 '07 #14
hariharanmca
1,977 1GB
Hello Hari,
One more problem occuring.
User Trim() function for the text box like...

Expand|Select|Wrap|Line Numbers
  1. Trim(txtStrValue.Text)
You have to explain what is that error?
Oct 3 '07 #15
Ali Rizwan
925 512MB
User Trim() function for the text box like...

Expand|Select|Wrap|Line Numbers
  1. Trim(txtStrValue.Text)
You have to explain what is that error?
Hello,

I have write this code

Expand|Select|Wrap|Line Numbers
  1.  
  2. Dim es As Integer
  3. es = SADD.txtTemp.Text
  4.  
  5.     ADATA.CommandType = adCmdUnknown
  6.     ADATA.RecordSource = "SELECT * FROM info WHERE Reg No Like '" &    SADD.txtTemp.Text & "' "
  7.     ADATA.Refresh
  8.     ADATA.Recordset.MoveFirst
  9.  
  10.  
and the error is in
Expand|Select|Wrap|Line Numbers
  1. ADATA.RecordSource = "SELECT * FROM info WHERE Reg No Like '" &    SADD.txtTemp.Text & "' "
and error is
Syntax error (missing operator) in query expression 'Reg No Like '3"

Thanx
Oct 3 '07 #16
hariharanmca
1,977 1GB
Access versions will not allow space between field names Check that.

Reg No should be RegNo
Oct 3 '07 #17
Ali Rizwan
925 512MB
Access versions will not allow space between field names Check that.

Reg No should be RegNo
No i have office XP 2004 and i have many fields with spaces like Roll No etc and access doesnot give any error.
Thanks
Oct 3 '07 #18
Killer42
8,435 Expert 8TB
Spaces within (not "between", Hari) field names are not a problem for Access. But if you're building an SQL string, I believe they can cause confusion. Putting [square brackets] around the field name may help.

As the error message indicated, the SQL interpreter didn't know what to make of "Reg No" - it took "Reg" as the field name, and couldn't work out what sort of operation "No" was supposed to indicate.
Oct 3 '07 #19
hariharanmca
1,977 1GB
Okay I agree...................................!
Oct 3 '07 #20
Killer42
8,435 Expert 8TB
:) It's just lucky the field name wasn't something like "Reg Like" or we could have some real confusion.
Oct 3 '07 #21
hariharanmca
1,977 1GB
:) It's just lucky the field name wasn't something like "Reg Like" or we could have some real confusion.
That's why i always suggest to use "_" or dont use space betueen field name.
i.e

if i use NameLike it do not show error but it will show error to
Name like. and same as

This reserved words
  • Description
  • Password
  • Name
  • Day
  • Month
  • Year…etc.
Oct 3 '07 #22
Ali Rizwan
925 512MB
Hello,
Killer i have tried this too i put two braces around it but nothing done error still occur but now i have changed the field names to RegNo and RollNo.
But now another error occurs but it is not syntax i think its logical.
On some forms the code searches right but on some it does not.
Hari please help how can i debug this.
Thanx
Oct 3 '07 #23
Killer42
8,435 Expert 8TB
Killer i have tried this too i put two braces around it but nothing done error still occur but now i have changed the field names to RegNo and RollNo.
If removing the spaces made a difference, then the square brackets should have worked. It might vary depending on what database we're talking about. But you indicated this was Access. Generally, the simplest way to get a query right for Access is to create it in the Query Designer in Access, then copy the SQL that it generates. As long as you don't mind it inserting dozens of extra parentheses, that is.

But now another error occurs but it is not syntax i think its logical.
On some forms the code searches right but on some it does not.
Hari please help how can i debug this.
Well, what is different between the forms? And can you show us the new code? And please provide full details about the new error.
Oct 4 '07 #24
Ali Rizwan
925 512MB
Well, what is different between the forms? And can you show us the new code? And please provide full details about the new error.
Thanx killer i have found the error.
I have made som echanges to code but on some codes i forgot to made changes.
Bu now its working.
Yhanx a lot
Oct 4 '07 #25
Killer42
8,435 Expert 8TB
Ok. Glad to see you managed to resolve your problem.
Oct 4 '07 #26

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

Similar topics

2
by: Sean Dodsworth | last post by:
Can anyone tell me how to get a message's number from the message-id using IMAP4.search? I've tried this: resp, items = server.search(None, 'HEADER', '"Message-id"', msgID) but it gives me a...
16
by: Stanley Sinclair | last post by:
Bear with me. I am being very calm; took a Valium. I have waited two weeks to write this, because every time I wrote it before the message was, at best, nasty. I need to use the services of...
4
by: Dica | last post by:
i apologize for what is no doubt a very rudimentary question, but i'm still trying to wrap my brain around .net coding habits. in classic asp, if i wanted to show search results, i'd just post the...
6
by: San | last post by:
Hey, I need to create a form with several text boxes in which users type in key words, press a command button on the form and it opens a matching record. Thanking you in advance.
0
by: Luis Corrales | last post by:
Hi all, I have a problem when searching for text with special characters in e-mails in an IMAP server. I'm using imaplib in python 2.4.3 and I can't get this code working: # first connect and...
3
by: Sheau Wei | last post by:
This is the search engine code that i create, but it was error and didnt come out the result. Cn u help me to check what wrong with my code? Thanks <Table cellspacing=1 cellPadding=1...
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...
12
by: ljungers | last post by:
I'm on the home streach of my project and found that my "Reset for New Search" command button not working as desired. What should happen is that when the button is clicked a Event Procedure is run....
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...
6
by: jej1216 | last post by:
I am trying to put together a PHP search page in which the user can select none, one, two, or three fields to search, and then the results php will build the SQL with dynamic where caluses to reflect...
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: 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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.