Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / May 2007

Tip: Looking for answers? Try searching our database.

Checking  a value in a recordset

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Stewart - 08 May 2007 04:48 GMT
I'm trying to test a 4 field, 1 row table, on form_open, to determine if
any one of the fields are empty or not.

But using this example, my If (Null or "")test is ignored:

Dim db As Database, RS As Recordset
 Set db = DBEngine.Workspaces(0).Databases(0)
 Set RS = db.OpenRecordset("SELECT * FROM tblSerial")
   If RS.BOF And RS.EOF Then
   'Do Error indication here
   End If
 Me!Testbox = RS![BaudRate] 'This does display value or blank
If RS![BaudRate]= Null Then 'Never happens regardless of value
  MsgBox "Baud Rate empty",,"Missing data"
End If

Is there a quick way to test to see if any field is empty?  Or just If
test each, one by one?

Any suggestions appreciated
Alex Dybenko - 08 May 2007 06:34 GMT
Hi,
try:
If isnull(RS![BaudRate]) Then

Signature

Best regards,
___________
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com

> I'm trying to test a 4 field, 1 row table, on form_open, to determine if
> any one of the fields are empty or not.
[quoted text clipped - 16 lines]
>
> Any suggestions appreciated
John Spencer - 08 May 2007 12:24 GMT
Or another alternative to test for both null and zero-length strings

If Len(RS!BaudRate & vbNullString) = 0 Then

or even more paranoid - null, zero-length strings, strings that are all
spaces

If Len(Trim(RS!BaudRate & VbNullString)) = 0 Then

Signature

John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
.

> Hi,
> try:
[quoted text clipped - 20 lines]
>>
>> Any suggestions appreciated
Stewart - 08 May 2007 13:28 GMT
That solved it.

Thanks

---
> Or another alternative to test for both null and zero-length strings
>
[quoted text clipped - 4 lines]
>
> If Len(Trim(RS!BaudRate & VbNullString)) = 0 Then
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.