Solved

Alternate text if databasefield is empty

Posted on 2014-03-03
4
216 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
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.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

757 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

19 Experts available now in Live!

Get 1:1 Help Now