Dealing with Null when assingning values to private variables

G

George

Hi to all,
Finally I decided to create a Client class but I have some difficulties. My
Clients form contains text boxes, some of them with string values, some with
dates, some with long integers, some with double and some with boolean
values. When I open my Clients form, I create a recordset based on my clients
table and then I assign the values of each field to private variables. Next I
use these private variables to fill all textboxes on my Clients form in the
form's Load event.
The problem appears when some client info is missing, that, is when there is
one or more null values in some field or fields in tblClients. In the case of
string values I use an If statement:

If Not IsNull(mrs.LName) Then
mstrLName = mrsLName
Else
mstrLName = Empty
End If

But how do I deal with the rest of the variables, i.e. dates (e.g. a missing
birthdate), long integers, double, and boolean when I have null values? Any
help would be greatly appreciated

thanks in advance, George
 
O

Ofer Cohen

To make it shorter try

mstrLName = Nz(mrs.LName,Empty)

The Nz will replace null with empty
Do the same for the rest of the variable
 
G

George

thanks Ofer,

your advice solved the problem. Whould you know now how I could avoid the
12/30/1899 date that the system assigns automatically when the birthdate is
missing?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top