Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

populating text box

Status
Not open for further replies.

NewProg

Programmer
Oct 18, 2002
3
0
0
US
Hi! I'm calling a function that should populate my part description text box if a part number matches a previous description. I'm getting an invalid use of Null error when I run it. Following is the code:

Private Sub EtcPartNum_LostFocus()

fillDescript

End Sub
---------------------
Sub fillDescript()

Dim db As Database
Dim rs As Recordset
Dim SQLString As String
Dim partNum As String
Set db = OpenDatabase("C:\Kim\IPBDatabase.mdb")

partNum = EtcPartNum.Text

SQLString = "select * from IPBListings where IPBListings.ETCPartNum = '" & partNum & "';"

Set rs = db.OpenRecordset(SQLString)

PartDescript.Text = rs.Fields("PartDescript")

rs.Close
db.Close

End Sub

Thanks!
 
Try trapping the condition. I've added the code to yours:

Sub fillDescript()
On Error Goto ERR_NO_MATCH

Dim db As Database
Dim rs As Recordset
Dim SQLString As String
Dim partNum As String
Set db = OpenDatabase("C:\Kim\IPBDatabase.mdb")

partNum = EtcPartNum.Text

SQLString = "select * from IPBListings where IPBListings.ETCPartNum = '" & partNum & "';"

Set rs = db.OpenRecordset(SQLString)

PartDescript.Text = rs.Fields("PartDescript")

rs.Close
db.Close

ERR_NO_MATCH:
PartDescription.Text = ""

End Sub


Haven't tested it but should allow the code to run...
Hope it helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top