|
-
Jan 30th, 2009, 06:11 AM
#1
Thread Starter
New Member
Empty DB field causing grief!!
HEllo all,
Should be a straightforward thing;
I have queried a table with field1, 2 and 3.
All fields are not always populated.
So when I allocated variables to, for instance, field3.
I will: field3var = rsMyRS![field3]
Now this will work if the field has got something in it, fair enough. And it the field is empty it will throw an error of :
invalid use of null
again, fair enough.
So to avoid the null error I wanted to put an if loop around like this:
Code:
If rsMyRS![field3] Is Null Then
Do something else
End If
But that doesnt work, and I get an Object required 424 error.
I have tried :
Code:
If rsMyRS![field3] is Empty...
And also
Code:
rsMyRS![field3] = ""
No luck.
Any ideas?
THanks
Ramo
-
Jan 30th, 2009, 07:10 AM
#2
Re: Empty DB field causing grief!!
How about
Code:
field3var = rsMyRS![field3] & vbNullString
-
Jan 30th, 2009, 07:45 AM
#3
Thread Starter
New Member
Re: Empty DB field causing grief!!
Thanks, but...
Althought that works, I dont think its particularly good coding...
Is there not a way of checking if a db field is empty before allocating a variable to it.
Ramo
-
Jan 30th, 2009, 07:54 AM
#4
Re: Empty DB field causing grief!!
-
Jan 30th, 2009, 08:42 AM
#5
Hyperactive Member
Re: Empty DB field causing grief!!
you could try
vb Code:
if len(rsMyRS![field3])=0 then
I normaly use rsMyRS(2) instead of having to type out the field names all the time. I find it easier to use as i can create a query and then add the fields in to excel and return the index by numbering each column.
cheers
David
-
Jan 30th, 2009, 10:22 AM
#6
Thread Starter
New Member
Re: Empty DB field causing grief!!
isNull is the cookie...
Thanks for your help (and advice with field references).
Ramo
-
Jan 30th, 2009, 10:58 AM
#7
Re: Empty DB field causing grief!!
I usually use If Not IsNull(whatever) Then
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|