Null values in Microsoft Access

Results 1 to 2 of 2

Thread: Null values in Microsoft Access

  1. #1
    Join Date
    Dec 1969

    Default Null values in Microsoft Access

    The following code:<BR><BR>if DATABASE_FIELD=Null then<BR> response.write "weee"<BR>else<BR> response.write "wooo"<BR>end if<BR><BR>does not do what I want it to do. It executes the second "else"-condition rather than the first "if"-condition, despite that I have set the database field to "Null" in Access.<BR><BR>Is this something that I need to take care of in Access, or is it the ASP code that is somehow wrong? I have set the field properties in Access to disallow zero length strings and not be required (which is what should do the trick and assign a Null-value to an empty field, according to the Access help file anyways).<BR><BR>Any suggestions?

  2. #2
    Sharon B. Guest

    Default RE: Null values in Microsoft Access

    I had the same problem some time ago.<BR><BR>To solve this you must understand the difference between an ASP (or VBScript) "Null" and an SQL "Null".<BR><BR>In ASP a VBScript "Null" looses its status as Null once it is assigned to or as a value. In other words nothing becomes "something" once I say it’s actually nothing ...comprende? Weird huh?!<BR>For example:<BR>&#060;%<BR>Dim x, y<BR>x = Null<BR>If IsNull(x) Then <BR>y = "Nothing"<BR>Else<BR>y = “Something”<BR>End IF<BR>%&#062;<BR>&#060;%=y%&#062; (= Something)<BR><BR>Not so for SQL, where a “Null” is actually Null (empty/zilch) and stays “Null” even after assigned Null. <BR><BR>So it seems that where you went wrong is by mixing and assigning a VBScript Null to an SQL RecordSet Field (DATABASE_FIELD=Null).<BR><BR>So why not try (works for me):<BR><BR>If IsNull(RecordSet(“FieldName”) then<BR>response.write "weee"<BR>else<BR>response.write "wooo"<BR>end if<BR><BR>Hope this helps you out and good luck!<BR>S.B.<BR><BR>P.S.: I posted a message a few lines below (“Object doesn’t support this property or method” - Sharon B.) and no one answered. Maybe you or one of your friends has an answer.<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts