hello experts . . .
i've designed a form (two textboxes and one commandbutton)
i wanna display id and user(fields of the table). and i display id and user on the basis of the id(inputted through textbox1).And for that i've written following code within command button's click event

Private Sub Command1_Click()
con.Provider = "Microsoft.Jet.OLEDB.4.0"
con.Open App.Path & "\db.mdb"
Dim query As String
query = "select * from tbl where id=" & Val(Text1.Text)
rec.Open query, con, 2, 3
Me.Text1.Text = rec!id
Me.Text2.Text = rec!user
Set con = Nothing
End Sub

i manually inputted data to the table (i inserted value to id field only and user field remained blank).

and now whenever i click on command button to retrieve data it produces an Error saying "Invalid use of Null".
Now what i want is when there is nothing in the user field then i wanna display the value "0".

so any solutions . . .

Edited by rishif2

5 Years
Discussion Span
Last Post by rishif2

i've already used if as following

If (rec.Fields(1) = Null) Then
Text1.Text = rec.Fields(0)
Text2.Text = 0
End If

but error still exist...

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.