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

problems with Null

Status
Not open for further replies.

jordanh

Technical User
Nov 11, 2002
47
GB
Ok, this is the simplest bit of code you'll see all day - that doesn't stop access having a serious logical problem with it though...

Private Sub Form_Open(cancel As Integer)
Dim upd1, upd2 As String
If Me!updatedby = Null Then
upd1 = " "
Else
upd1 = Me!updatedby
End If
If Me!updatedon = Null Then
upd2 = " "
Else
upd2 = Me!updatedon
End If
DoCmd.Maximize
End Sub

Run-time Error! Invalid use of null (highlights

upd2 = Me!updatedon

line). A bit of mouse hovering and it tells me that Me!updateon = Null. But if that's the case, why hasn't it skipped the Else?

I'm confused....

any ideas would be appreciated.

Jordan
 
Don't use:

something = Null

Instead use:

IsNull(something)

you do you:

something = ""

which looks for the empty string...which is very different than null Only two things are infinite, the universe and human stupidity, and I'm not sure about the former. (Albert Einstein)

Robert L. Johnson III, MCP, Network+, A+
Access Developer/Programmer
robert.l.johnson.iii@citigroup.com
 
You might try the following code instead:
[tt]
If IsNull(Me!updateby) = True Then
upd1 = Space(1)
Else
upd1 = Me!updateby
Endif
...
[/tt]
hth,
GGleason

 
and it's as simple as that...

cheers.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top