Solved

Alternate text if databasefield is empty

Posted on 2014-03-03
4
224 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 143

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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

726 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