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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Case statement - Case is null

Status
Not open for further replies.

kpal29

Technical User
Feb 8, 2003
147
DK
I need to determine if a value of a field is null in a Case statement - I can't figure out the correct syntax
Here is my code:

Select Case rs!reference_no
Case "FILES REMAINING OPEN FROM THE PERIOD"
rs.Delete

Case Is = Null
rs.Delete

End Select

Please advise
Thanks
 
If you mean empty string, use
Case ""

If you mean null, use
Case Null

*cLFlaVA
----------------------------
Breaking the habit...
 
Hi,

Realize that in VB, "" and NULL mean TWO DIFFERENT THINGS.

Skip,

[glasses] [red]Be advised:[/red] When transmitting sheet music...
If it ain't baroque, don't fax it! [tongue]
 
Have tried both w/o success - here is my whole code:

Sub DeleteGarbage()
Dim DB As dao.Database
Dim rs As dao.REcordset
Set DB = DBEngine.Workspaces(0).Databases(0)
Set rs = DB.OpenRecordset("Import")
Do While Not rs.EOF

Select Case rs![REFERENCE_NO]
Case "FILES REMAINING OPEN FROM THE PERIOD", "TOTAL FOR FILES REMAINING OPEN FROM THE PERIOD", _
"CLOSED FILES", "PRIOR PERIOD POST-CLOSING EXCEPTIONS OCCURING DURING THE PERIOD", "Totals", "TOTAL CLOSED FILES"
rs.Delete

Case null rs.Delete

End Select

rs.MoveNext
Loop
rs.Close
End Sub
 
Are you getting an error message of any sort? Can you pop a messagebox to display the actual value in rs![REFERENCE_NO]?

You might also want to try trimming first:

Select Case Trim(rs![REFERENCE_NO])

*cLFlaVA
----------------------------
Breaking the habit...
 
Code:
    Select Case rs![REFERENCE_NO]
    Case Null, "", "FILES REMAINING OPEN FROM THE PERIOD", "TOTAL FOR FILES REMAINING OPEN FROM THE PERIOD", _
    "CLOSED FILES", "PRIOR PERIOD POST-CLOSING EXCEPTIONS OCCURING DURING THE PERIOD", "Totals", "TOTAL CLOSED FILES"
        rs.Delete

    End Select


Skip,

[glasses] [red]Be advised:[/red] When transmitting sheet music...
If it ain't baroque, don't fax it! [tongue]
 
I am not getting an error - I debug.printed in the immediate window all values where Reference_no = null and they showed up as null - Can't figure this one out?
 
Also, this file is a .csv imported with a transfertext method. When I open the.csv in Excel and select an empty reference_no cell and press f2 - I can see there are 20 spaces in the cell - I tried trim and "" with 20 spaces in between also.
 
Did you try
Code:
Case  ""
???

Skip,

[glasses] [red]Be advised:[/red] When transmitting sheet music...
If it ain't baroque, don't fax it! [tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top