I found this example in a previous thread in which the user enters a number in a textbox (PartNo) and the code returns the matching recordset from selected fields in the same table. Code works when PartNo is a numeric data type but in my case PartNo is a text data type (example: D1345). How would I get this to work with a text data type? Thanks in advance,
Private Sub txtPartNo_AfterUpdate()
Dim rst As DAO.Recordset
Dim sql As String
sql = "Select * From Contents Where PartNo =" & Me!txtPartNo
Set rst = CurrentDb.OpenRecordset(sql, dbOpenDynaset)
If rst.EOF = True And rst.BOF = True Then
Call MsgBox("The Part Number you entered does not exist"
Else
Me!txtPartName = rst!PartName
Me!txtPieces = rst!Pieces
Me!txtPrice = rst!Price
End If
Set rst = Nothing
End Sub
Set rst = Nothing
End Sub
Private Sub txtPartNo_AfterUpdate()
Dim rst As DAO.Recordset
Dim sql As String
sql = "Select * From Contents Where PartNo =" & Me!txtPartNo
Set rst = CurrentDb.OpenRecordset(sql, dbOpenDynaset)
If rst.EOF = True And rst.BOF = True Then
Call MsgBox("The Part Number you entered does not exist"
Else
Me!txtPartName = rst!PartName
Me!txtPieces = rst!Pieces
Me!txtPrice = rst!Price
End If
Set rst = Nothing
End Sub
Set rst = Nothing
End Sub