Connecting Tech Pros Worldwide Forums | Help | Site Map

Invalid use of Null error

Familiar Sight
 
Join Date: Jan 2008
Posts: 137
#1: Jan 3 '09
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



Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub cmbPoNo_Click()
  3. Dim Rs As New ADODB.Recordset
  4. If cmbPoNo.Text <> "" Then
  5. txtPoYear.Text = ""
  6. txtAmendno.Text = ""
  7. txtPoAmount.Text = ""
  8. txtpotax.Text = ""
  9. txtUnitId.Text = ""
  10. txtdiscount.Text = ""
  11. If Rs.State = adStateOpen Then Rs.Close
  12. Rs.Open ("select * from TxPoHdr Where PoNo = '" & cmbPoNo.Text & "'And Ind ='1' And yy = '" & FinancialYear & "' "), Db, adOpenKeyset, adLockPessimistic
  13. If Not (Rs.BOF And Rs.EOF) Then
  14. txtPoAmount.Text = Rs.Fields("PoAmt").Value
  15. txtpotax.Text = Rs.Fields("PoTax").Value
  16. txtAmendno.Text = Rs.Fields("AmendNo").Value
  17. txtUnitId.Text = Rs.Fields("Unitid").Value
  18. txtPoYear.Text = Rs.Fields("YY").Value
  19. txtdiscount.Text = Rs.Fields("Discount").Value
  20. End If
  21. End If
  22.  
  23. If cmbPoNo.Text <> "" Then
  24. Adodc2.ConnectionString = pStrConnectionString
  25. 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 "
  26. Adodc2.Refresh
  27. MSHFlexGrid2.ColWidth(1) = 1000
  28. MSHFlexGrid2.ColWidth(2) = 700
  29. MSHFlexGrid2.ColWidth(3) = 700
  30. MSHFlexGrid2.ColWidth(4) = 700
  31. MSHFlexGrid2.ColWidth(5) = 1200
  32. MSHFlexGrid2.ColWidth(6) = 1200
  33. MSHFlexGrid2.ColWidth(7) = 1200
  34. MSHFlexGrid2.ColWidth(8) = 2500
  35. MSHFlexGrid2.ColWidth(9) = 1800
  36. MSHFlexGrid2.ColWidth(10) = 400
  37. MSHFlexGrid1.ColWidth(11) = 1000
  38. MSHFlexGrid2.Refresh
  39. End If
  40. End Sub
  41.  

QVeen72's Avatar
Moderator
 
Join Date: Oct 2006
Location: Bangalore
Posts: 1,385
#2: Jan 3 '09

re: Invalid use of Null error


Hi,

Try This :

Expand|Select|Wrap|Line Numbers
  1. txtdiscount.Text = Rs.Fields("Discount").Value & ""
  2.  
Regards
Veena
Familiar Sight
 
Join Date: Jan 2008
Posts: 137
#3: Jan 3 '09

re: Invalid use of Null error


Thank u very much.. it worked :)))))))
lotus18's Avatar
Site Addict
 
Join Date: Nov 2007
Location: Zamboanga City, Philippines
Posts: 860
#4: Jan 3 '09

re: Invalid use of Null error


Or you may also try
Expand|Select|Wrap|Line Numbers
  1. 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
Reply