Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB6 ListView MS-Access
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
surkhi623
Edited 22-May-13 7:18am
Maciej Los158.9K
v3
Comments
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
good
Please Sign up or sign in to vote.

Solution 1

You can't do it in one command! Why? Please, read ryanb31 comment.
 
1)
UPDATE [note] set flag="on" 
WHERE doc_type="credit"
 
2)
UPDATE [note] set flag="on" 
WHERE doc_no like "121*"
 
Please, follow this link: Examples of query criteria (MS Access)[^]
  Permalink  
Comments
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 350
1 Jochen Arndt 190
2 Richard MacCutchan 135
3 Sergey Alexandrovich Kryukov 130
4 DamithSL 105
0 OriginalGriff 6,045
1 DamithSL 4,601
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,310


Advertise | Privacy | Mobile
Web04 | 2.8.141220.1 | Last Updated 22 May 2013
Copyright © CodeProject, 1999-2014
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