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
con.Close
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 . . .

Use an if to see if the rec or user value is null (or empty) before you assign it to the textbox.

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...

i got the solution with isnull statement

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.