Solved

Alternate text if databasefield is empty

Posted on 2014-03-03
4
220 Views
Last Modified: 2014-03-03
If databasefield "soll_uitgenodigd" AND databasefield "soll_afgewezen" are both empty, I like to response write an alternate text. Below code only the "ja" and "nee" code is working:

          <% If  (rsSolliOverzicht.Fields.Item("soll_uitgenodigd").Value) = "ja" Then %>
          <span class="toptabGROEN">JA</span>
		  <% End If %>
          <% If  (rsSolliOverzicht.Fields.Item("soll_afgewezen").Value) = "ja" Then %>
          <span class="toptabROOD">NEE </span>
          <% End If %>
          <% If (rsSolliOverzicht.Fields.Item("soll_afgewezen").Value) = "" AND (rsSolliOverzicht.Fields.Item("soll_uitgenodigd").Value)= "" Then %>
          <span>geen reactie</span>
		  <% End If %> 

Open in new window


Anyone?
0
Comment
Question by:hanskoens
  • 2
4 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 39900112
if you refer to "empty", it is probably rather "null" than that string value...
anyhow, you may want to do like this (or some other method, for example keeping a boolean value within the if or else stuff ...
          <% If  (rsSolliOverzicht.Fields.Item("soll_uitgenodigd").Value) = "ja" Then %>
          <span class="toptabGROEN">JA</span>
		  <% End If %>
          <% If  (rsSolliOverzicht.Fields.Item("soll_afgewezen").Value) = "ja" Then %>
          <span class="toptabROOD">NEE </span>
          <% End If %>
          <% If (rsSolliOverzicht.Fields.Item("soll_afgewezen").Value) <> "ja" AND (rsSolliOverzicht.Fields.Item("soll_uitgenodigd").Value) <> "ja" Then %>
          <span>geen reactie</span>
		  <% End If %>  

Open in new window

0
 
LVL 52

Accepted Solution

by:
Scott Fell,  EE MVE earned 250 total points
ID: 39900116
<%
dim soll_afgewezen, soll_uitgenodigd
soll_afgewezen=""
soll_uitgenodigd=""
if not isnull(rsSolliOverzicht.Fields.Item("soll_afgewezen").Value) Then
	soll_afgewezen=rsSolliOverzicht.Fields.Item("soll_afgewezen").Value
end if
if not isnull(rsSolliOverzicht.Fields.Item("soll_uitgenodigd").Value) Then
	soll_uitgenodigd=rsSolliOverzicht.Fields.Item("soll_uitgenodigd").Value
end if
if soll_uitgenodigd="ja" Then
	response.write "<span class=""toptabGROEN"">JA</span>"
end if
if soll_afgewezen="ja" Then
	response.write "<span class=""toptabROOD"">JA</span>"
end if
if soll_afgewezen="" and soll_uitgenodigd="" Then
	response.write "<span>geen reactie</span>"
end if

%>

Open in new window


But what happens if soll_afgewezen="ja" and soll_uitgenodigd=""? or the other way around.
0
 
LVL 2

Author Comment

by:hanskoens
ID: 39900123
@ Guy Hengel [angelIII / a3]: sorry but the same results I had before.
@ Scott Fell (padas): Thank you man, this works for me (except you used 2x "ja" instead of "ja" and "nee", but that was just a typo :)
0
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
ID: 39900130
I also have a hard time in my own language let alone another...
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…

863 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