Solved

set field to blank with sql

Posted on 2004-08-18
11
412 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
ID: 11838058
Try this:

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

Expert Comment

by:dsacker
ID: 11838063
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
ID: 11838128
didn't work..
0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
LVL 20

Expert Comment

by:dsacker
ID: 11838156
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
 

Author Comment

by:rembocanoe
ID: 11838180
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
ID: 11838234
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
ID: 11838572
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
ID: 11841987
Try this


SQL = SQL & "TeamCode = null "


Melih SARICA
0
 
LVL 2

Expert Comment

by:Shahankit
ID: 11846339
Try This

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

OR
SQL = SQL & "TeamCode =" & Null

good Luck
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Cannot install / add SQL database when installing MyCalls software 22 103
Multiple MSSQL instances on same server 4 40
Mysql Left Join Case 10 52
error in my cursor 5 29
CCModeler offers a way to enter basic information like entities, attributes and relationships and export them as yEd or erviz diagram. It also can import existing Access or SQL Server tables with relationships.
Read about achieving the basic levels of HRIS security in the workplace.
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…

776 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