[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

locating null fields in an access database

Posted on 2000-04-24
4
Medium Priority
?
153 Views
Last Modified: 2010-05-02
Is there a way (through vb code) to change all null fields in a very large table to empty strings  without reading each field.

 
0
Comment
Question by:Diehl
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 2

Expert Comment

by:Crin
ID: 2744515
First you should be certitude that empty strings are allowed.

Then use
Database.Execute "Update Table set Field = '' where IsNull(Field);"

This should work.

Sincerely yours,

Crin
0
 
LVL 6

Expert Comment

by:Marine
ID: 2744569
This should work .

UPDATE <tableName> SET <tableField> = "" WHERE <fieldname>=Null
0
 
LVL 32

Accepted Solution

by:
Brendt Hess earned 200 total points
ID: 2744651
If it is more than one field that can be null, you'll have to execute the above queries more than once.

The best method depends on what access method you are using.  I'm going to use a DAO example, but ADO can be done just about the same way.

This procedure requires you to pass the opened Database that the table is in, and a table name.

Sub ClearNulls(db As Database, tName as String)
Dim S as String, I as Integer, J as Integer

For I = 0 to db.TableDefs.Count - 1
  ' find the tabledef
  If UCase(db.TableDefs(I).Name) = UCase(tName) Then
    ' once found, get the fields from the tabledef
    With db.Tabledefs(I)
      For J = 0 to .Fields.Count - 1
        ' only update text or memo fields
        If .Fields(J).Type = dbText or .Fields(J).Type = dbMemo Then
          ' execute an SQL statement to set nulls to empty strings (assumes this is allowed)
          db.Execute "UPDATE " & tName & " SET " & .Fields(J).Name & " = '' Where IsNull(" & .Fields(J).Name & ");"
        End If
      Next J
    End With
  End If
Next I    
0
 
LVL 6

Expert Comment

by:Marine
ID: 2745112
I don't think so bhess1 i can execute it only once and update all fields whcih will contain null values. I don't even have to specify where condition and all colums will be updated to "" if they contain null
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses

649 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