Solved

Using Data Controls and Nulls

Posted on 1998-07-16
3
121 Views
Last Modified: 2010-05-18
Hi.  I have created a simple application.   It has a dBase database with only 2 fields.  Name, and age.  Name
is a text field, and age is a numeric field.    On my VB app, I have a data control linked to the database, and two text boxes linked to the fields.  I have another button labeled Update.   When I run the program, I use my data
control to move through the records.  But, if I stop on a record, and delete the age that was there, and hit my update button, it  gives me a data conversion error, because I'm not storing a numeric value in the age field.  How can I
make my program allow storing of empty strings in a numeric field???

0
Comment
Question by:ssteeves
3 Comments
 
LVL 8

Accepted Solution

by:
MikeP090797 earned 80 total points
ID: 1465970
There is no way you can store string in such field, but you can store 0, and when your record loads, replace it with "" in the textbox
0
 
LVL 14

Expert Comment

by:waty
ID: 1465971
You could use a function like the following. It works in all the
cases, and doesn't break for NULL values.

Function ReadRecordSet(record As Recordset, szChamps As String)
   ' *** Check for NULL value

   If IsNull(record(szChamps)) Then
      Select Case VarType(record(szChamps))
         Case vbLong: ReadRecordSet = 0
         Case vbString: ReadRecordSet = ""
         Case vbDate: ReadRecordSet = "01/01/1980"
      End Select
   Else
      ReadRecordSet = record(szChamps)
   End If

End Function

0
 
LVL 1

Author Comment

by:ssteeves
ID: 1465972
That's pretty much what I did.  Thanks for the help guys.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

920 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

14 Experts available now in Live!

Get 1:1 Help Now