Click here to Skip to main content
15,897,518 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
VB
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
Updated 22-May-13 6:18am
v3
Comments
[no name] 22-May-13 8:31am    
What sort of a "result" are you expecting from an UPDATE statement?
What exactly does "is not working" mean?
ZurdoDev 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

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

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


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


Please, follow this link: Examples of query criteria (MS Access)[^]
 
Share this answer
 
Comments
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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900