Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Default value --> NULL

Status
Not open for further replies.

laado

Programmer
Oct 17, 2002
35
AU
Hi Guys

We do some reports by importing DBF files in Access,
The problem i have got is sometimes a value (Numeric)which is read as 0 in Clipper But in Access it becomes Empty,

For Example , If i add a new record in our Products.dbf, the onhand values are set as 0 (By Default), I have no problem doing reports if i use Clipper, but if i am doing same reports use Sql and i say i need all products with
onhand value equals 0 it skips pass the it...

** same thing happens with Logical type values **

Thanks in advance

Daljinder


 
Daljinder,

Here's a solution that I used for those pesky fields that Clipper interprets as filled, yet SQL, Access & Visual Basic see them as NULL. This function works with controls, too.

Function CZero( _
Optional cString As String = "") As Variant

On Error Resume Next

Dim nReturn As Variant

nReturn = 0
cString = "" & cString

Select Case True
Case IsMissing(cString)
nReturn = 0
Case IsEmpty(cString)
nReturn = 0
Case IsNull(cString)
nReturn = 0
Case cString = ""
nReturn = 0
Case Trim(cString) = ""
nReturn = 0
Case Else
nReturn = CVar(CSng(cString))
End Select

CZero = nReturn

Exit Function

End Function

I hope this helps,
Kevin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top