0

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

3
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by debasisdas
0

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.

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.