Click here to Skip to main content
11,805,604 members (53,029 online)
Rate this: bad
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 2:27am
Edited 22-May-13 6:18am
Maciej Los202.4K
ThePhantomUpvoter at 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 at 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 at 23-May-13 6:52am
k thanks for the help...
Maciej Los at 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
0 OriginalGriff 310
1 Richard Deeming 225
2 Sergey Alexandrovich Kryukov 170
3 Abhinav S 128
4 ppolymorphe 125
0 OriginalGriff 3,300
1 Maciej Los 1,990
2 KrunalRohit 1,907
3 CPallini 1,855
4 Richard MacCutchan 1,227

Advertise | Privacy | Mobile
Web04 | 2.8.151002.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