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 Los172.1K
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 475
1 Sergey Alexandrovich Kryukov 405
2 Maciej Los 290
3 ProgramFOX 265
4 CHill60 200
0 OriginalGriff 490
1 Sergey Alexandrovich Kryukov 405
2 Maciej Los 285
3 ProgramFOX 265
4 Peter Leow 210


Advertise | Privacy | Mobile
Web02 | 2.8.150331.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