Solved

set field to blank with sql

Posted on 2004-08-18
11
409 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
 
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
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 

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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

In today’s complex data management environments, it is not unusual for UNIX servers to be dedicated to a particular department, purpose, or database.  As a result, a SAS® data analyst often works with multiple servers, each with its own data storage…
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…

867 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

21 Experts available now in Live!

Get 1:1 Help Now