Hi,

I m inserting Record in Access using VB6 SQL statement as follows

Dim str As String
On Error GoTo solve
str = "INSERT INTO [compinfo]([cID],[cname],[address],[add2],[city],[Postno],[mob],[phno],[faxno],[email],[workday],[offtime],[saldate],[duedate],[amount],[paytyp],[web],[type],[expdat],[charge]) values (" & "'" & txtcomid.Text & "'" & _
            "," & "'" & txtcomnam.Text & "'" & "," & "'" & txtcomadd.Text & "'" & "," & "'" & txtcomadd2.Text & "'" & _
            "," & "'" & txtcity.Text & "'" & _
            "," & txtposton.Text & _
            "," & "'" & txtmob.Text & "'" & _
            "," & "'" & txtphone.Text & "'" & _
            "," & txtfax.Text & _
            "," & "'" & txtemail.Text & "'" & "," & "'" & Comwday.Text & "'" & _
            "," & "'" & txtofftim.Text & "'" & _
            "," & Comsaldat.Text & _
            "," & "'" & DTPpay.Value & "'" & _
            "," & Txtamount.Text & _
            "," & "'" & Compaytyp.Text & "'" & _
            "," & "'" & txtwebadd.Text & "'" & _
            "," & "'" & Comtype.Text & "'" & _
            "," & "#" & expdat.Value & "#" & _
            "," & "'" & Comchar.Text & "'" & ")"
    
            
con.Execute str
solve:
If Err.Number = -2147217900 Then
MsgBox "Enter All the Fields...", vbCritical
On Error GoTo solve
Else
MsgBox "Your Record Has Been Addedd Successfully . . . ", vbInformation
End If

But this statement does not allows me Leave Blank Text boxes means
it does not allows me to insert NULL value
if i leave any textbox BLANK it generate ERROR -2147217900:(

HOW to solve this Problem, In my project it is not necessary to insert all records.
when we leave blank Text box it genrate Error:'(

So PLEASE send me code or IDEA to solve this problem
Thanks for Reading My Question

Look in your Access database. Check the attributes of the fields for the columns...check allow NULL values. This should solve it. Then you can insert a NULL value easily.

what happens if you insert NULL to the field ?

is there any constraints on the database table fields.

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.