Invalid use of Null error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • squrel
    New Member
    • Jan 2008
    • 143

    Invalid use of Null error

    Hi everyone..

    i have added one textbox called discount to one of my form to display the discount if it exists and also to enter in the textbox... i have button called viewall which is in the FormUpdateSQL1. .. when i open the viewall window and click on the particular row and click on the buttion view selected on i m getting this error : Invalid use of Null.. i have changed everything which i knew.. i dont knw wht else i should do..
    i m sending u the code.. the bold line is whr i m getting the error
    wld u plz help me out here..
    thank u very much



    Code:
     
    Private Sub cmbPoNo_Click()
    Dim Rs As New ADODB.Recordset
    If cmbPoNo.Text <> "" Then
    txtPoYear.Text = ""
    txtAmendno.Text = ""
    txtPoAmount.Text = ""
    txtpotax.Text = ""
    txtUnitId.Text = ""
    txtdiscount.Text = ""
    If Rs.State = adStateOpen Then Rs.Close
    Rs.Open ("select * from TxPoHdr Where PoNo = '" & cmbPoNo.Text & "'And Ind ='1' And yy = '" & FinancialYear & "' "), Db, adOpenKeyset, adLockPessimistic
    If Not (Rs.BOF And Rs.EOF) Then
    txtPoAmount.Text = Rs.Fields("PoAmt").Value
    txtpotax.Text = Rs.Fields("PoTax").Value
    txtAmendno.Text = Rs.Fields("AmendNo").Value
    txtUnitId.Text = Rs.Fields("Unitid").Value
    txtPoYear.Text = Rs.Fields("YY").Value
    txtdiscount.Text = Rs.Fields("Discount").Value
    End If
    End If
     
    If cmbPoNo.Text <> "" Then
    Adodc2.ConnectionString = pStrConnectionString
    Adodc2.RecordSource = " Select Bill.BillSrl,Bill.YY,Bill.PoNo,Bill.BillNo ,Bill.BillAmt,Bill.BillTax,convert(VarChar(20), Bill.BillDate, 6) As BillDate,Unit.UnitNm,Ven.VendorNm,Bill.Ind,Bill.discount from TxBills Bill, MsUnits Unit, MsVendors Ven Where Bill.UnitId = Unit.UnitId And Bill.VendorId = Ven.VendorId and Bill.YY = " & FinancialYear & " and Bill.PoNo = " & cmbPoNo.Text & " and Bill.VendorId = " & txtVendorId.Text & " order by Bill.BillSrl "
    Adodc2.Refresh
    MSHFlexGrid2.ColWidth(1) = 1000
    MSHFlexGrid2.ColWidth(2) = 700
    MSHFlexGrid2.ColWidth(3) = 700
    MSHFlexGrid2.ColWidth(4) = 700
    MSHFlexGrid2.ColWidth(5) = 1200
    MSHFlexGrid2.ColWidth(6) = 1200
    MSHFlexGrid2.ColWidth(7) = 1200
    MSHFlexGrid2.ColWidth(8) = 2500
    MSHFlexGrid2.ColWidth(9) = 1800
    MSHFlexGrid2.ColWidth(10) = 400
    MSHFlexGrid1.ColWidth(11) = 1000
    MSHFlexGrid2.Refresh
    End If
    End Sub
  • QVeen72
    Recognized Expert Top Contributor
    • Oct 2006
    • 1445

    #2
    Hi,

    Try This :

    [code=vb]
    txtdiscount.Tex t = Rs.Fields("Disc ount").Value & ""
    [/code]

    Regards
    Veena

    Comment

    • squrel
      New Member
      • Jan 2008
      • 143

      #3
      Thank u very much.. it worked :)))))))

      Comment

      • lotus18
        Contributor
        • Nov 2007
        • 865

        #4
        Or you may also try
        Code:
        On Error Resume Next
        . Just add this line above it. It just escapes the the error occurred. However it is not recommended to use this, you may only use this for special purpose.


        Rey Sean

        Comment

        Working...