Click here to Skip to main content
11,927,156 members (53,424 online)
Rate this:
Please Sign up or sign in to vote.
See more: VB6 Access ListView
sql = "update [note] " & _
" set flag='on' " & _
" where doc_type='credit' " & _
" and doc_type='debit' and doc_no like " & "'" & text1 & "%'"

This code doesn't return any result though I'm having records in database...

DOC_NO  	DOC_TYPE  RETURN	FLAG                
121001	        DEBIT                   off    //on
666	        CREDIT    121002        off    //on
122004		DC                      off
888		CREDIT    121005        off    //on
122006		DC                      off

Now I want to make flag 'on' of those records which are
[1] credited and
[2] debited as well as having doc_no='121%'(for ex. text1 has 121 typed)
I tried above code which is not working ...can anyone help me.....
Posted 22-May-13 3:27am
Edited 22-May-13 7:18am
Maciej Los210.1K
ThePhantomUpvoter 22-May-13 8:31am
What sort of a "result" are you expecting from an UPDATE statement?
What exactly does "is not working" mean?
ryanb31 22-May-13 11:04am
That's because you have "WHERE doc_type='credit' AND doc_type='debit'" It can't be both credit and debit.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

You can't do it in one command! Why? Please, read ryanb31 comment.

UPDATE [note] set flag="on" 
WHERE doc_type="credit"

UPDATE [note] set flag="on" 
WHERE doc_no like "121*"

Please, follow this link: Examples of query criteria (MS Access)[^]
surkhi 23-May-13 6:52am
k thanks for the help...
Maciej Los 23-May-13 6:53am
You're welcome ;)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web03 | 2.8.151126.1 | Last Updated 22 May 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100