Solved

set field to blank with sql

Posted on 2004-08-18
11
407 Views
Last Modified: 2012-05-05
I have a simulated drag and drop between list boxes. I need to set one of the fields to blank if draged to one of the boxes. Every thing works but that. I'm trying single quotes within the double quotes. I've tried Null too but nothing seems to work.
Here is the line in question:
SQL = SQL & "TeamCode = ''"
I want teamcode to be "" (Blank)
Any suggestions?



SQL = "UPDATE tbl_PlayerInfo SET "
      Select Case DropCtrl.Name
      Case "TeamPlayers"
    SQL = SQL & "TeamCode =" & "'" & Forms!frm_Teamcode!Tcodecmbo & "'"
      Case "ReqPlayers"
    SQL = SQL & "TeamCode = '', ReqTeam = " & "'" & Forms!frm_Teamcode!Tcodecmbo & "'"
      Case "NPlayers"
    SQL = SQL & "TeamCode = ''"
      Case "VPlayers"
    SQL = SQL & "TeamCode =" & "'" & Forms!frm_Teamcode!Vteam & "'"
   End Select
   
   If (Shift And CTRL_MASK) = 0 Then
   SQL = SQL & " WHERE [tbl_PlayerInfo.ID]=" & DragCtrl
   End If

   DB.Execute SQL

thanks
Ray
0
Comment
Question by:rembocanoe
11 Comments
 
LVL 20

Expert Comment

by:dsacker
Comment Utility
Try this:

SQL = SQL & "TeamCode = """""
0
 
LVL 20

Expert Comment

by:dsacker
Comment Utility
The trick is that two doublequotes equals one displayed doublequote, hence the five doublequotes will actually be two displaying one, two more displaying one, then the final doublequote ending the string definition.
0
 

Author Comment

by:rembocanoe
Comment Utility
didn't work..
0
 
LVL 20

Expert Comment

by:dsacker
Comment Utility
Can you display the value of SQL and verify that your SQL statement shows that TeamCode = ""?

Also, it may be that you need to add a space between whatever SQL had in it and the forthcoming case logic that appends to it, else you may have the last word of the previous part of that SQL string and the first word of the appended string in your case logic WITHOUT a space in between them. You can verify that by displaying the value of SQL as you go along.
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:rembocanoe
Comment Utility
I used a msgbox to check my variable and it is TeamCode = "".

What I ended up doing is setting it to TeamCode = " " then changed my list query to find " " as well as Null and "". This fixed my problem but didn't teach me anything. LOL

Thanks
Ray
0
 
LVL 20

Expert Comment

by:dsacker
Comment Utility
Seems you should have been able to assign SQL = SQL & "TeamCode = Null" to begin with, but your original posting sounded like you had tried that. Technically, that's the cleanest way.
0
 
LVL 1

Expert Comment

by:Parag_Gujarathi
Comment Utility
Use SQL & "TeamCode = ' '" i.e. put a blank space between the single quotes. No space between single quotes is treated as NULL!

cheers
Parag.
0
 
LVL 19

Accepted Solution

by:
Melih SARICA earned 500 total points
Comment Utility
Try this


SQL = SQL & "TeamCode = null "


Melih SARICA
0
 
LVL 2

Expert Comment

by:Shahankit
Comment Utility
Try This

set escape \
SQL = SQL & "TeamCode= \"Null" "

OR
SQL = SQL & "TeamCode =" & Null

good Luck
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now