Question:
i need help in my code(vb6 to MsAccess db).i get the error "invalid use of null"?
?
2009-10-30 00:26:35 UTC
it is a basic form(my first).
i know its too much to ask for........but if possible,pls go through my code. the form has only 3 cmd boxes(add record,save and close) and 2 text boxes (first name and last name)



Dim con As New ADODB.Connection
Dim rs As New ADODB.Recordset


Private Sub cmdAdd_Click()
txtFirstName.Text = ""
txtLastName.Text = ""
cmdSave.Enabled = True
End Sub

Private Sub cmdClose_Click()
End
End Sub

Private Sub cmdFirst_Click()
rs.MoveFirst
If rs.EOF = False Then
txtFirstName.Text = rs.Fields(1)
txtLastName.Text = rs.Fields(2)
End If
End Sub

Private Sub cmdLast_Click()
rs.MoveLast
If rs.EOF = False Then
txtFirstName.Text = rs.Fields(1)
txtLastName.Text = rs.Fields(2)
End If
End Sub

Private Sub cmdNext_Click()
rs.MoveNext
If rs.EOF = False Then
txtFirstName.Text = rs.Fields(1)
txtLastName.Text = rs.Fields(2)
End If
End Sub

Private Sub cmdPrev_Click()
rs.MovePrevious
If rs.EOF = False Then
txtFirstName.Text = rs.Fields(1)
txtLastName.Text = rs.Fields(2)
End If
End Sub

Private Sub cmdSave_Click()
If rs.State Then rs.Close
rs.Open "Select * from basic", con, adOpenKeyset, adLockOptimistic
rs.AddNew
rs.Fields(1) = txtFirstName.Text
rs.Fields(2) = txtLastName.Text
rs.Update
cmdSave.Enabled = False
Form_Load
MsgBox "Record Added Successfully"
End Sub

Private Sub Command1_Click()

End Sub

Private Sub Form_Load()
Set con = Nothing
con.Open "DSN=TTT"
Set rs = Nothing
rs.Open "Select * from basic", con, adOpenKeyset, adLockOptimistic
If rs.RecordCount > 0 Then
txtFirstName.Text = rs.Fields(1)
txtLastName.Text = rs.Fields(2)
End If
End Sub
Four answers:
Karunagara
2009-10-30 00:33:20 UTC
This error will occur when you try to move across the rows which has the null values.



If anyone column has null value in your table, this error will occur. So, check whether it is or not!



Need Help : gkpandi07.wings@gmail.com



Best Of Luck
2016-12-18 21:55:36 UTC
format with the domicile windows xp/vista disc. start up your laptop, positioned the disc interior thepersistent. watch for a "press any key as nicely from cd/dvd message" and press any key. pass for the period of the stairs to format your laptop and reinstall domicile windows.
2009-10-30 02:02:36 UTC
You are submit a null value into a field that requires a value.
2016-12-13 11:33:05 UTC
format with the living house windows xp/vista disc. commence your laptop, positioned the disc in the stress. look ahead to a "press any key besides from cd/dvd message" and press any key. circulate by the stairs to format your laptop and reinstall living house windows.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...