P
pido
Guest
Hi im newbie in access programing for form, and I have a problem in my Form.
Basicaly i have Order Form with a subForm which is Order details. Record source for my subForm is a qry_orderDetails that i made, TextBoxes are 'PK_partNumber,partName,and partPrice'
What i want is when i put textBox 'PK_partNumber' lets take '12345' and i want field 'partName' automatically search in my 'tbl_sparePart' table and put its Name in the 'partName' field
Should i make a code using Visual Basic Code and make my own query to search the textBox 'PK_partNumber'?? bcuz i tried it but it give me an error saying "#Name"
this is my code:
anyone can help me?? i would be appreciate it.. Thnx in advanced
Basicaly i have Order Form with a subForm which is Order details. Record source for my subForm is a qry_orderDetails that i made, TextBoxes are 'PK_partNumber,partName,and partPrice'
What i want is when i put textBox 'PK_partNumber' lets take '12345' and i want field 'partName' automatically search in my 'tbl_sparePart' table and put its Name in the 'partName' field
Should i make a code using Visual Basic Code and make my own query to search the textBox 'PK_partNumber'?? bcuz i tried it but it give me an error saying "#Name"
this is my code:
Code:
Private Sub partNumber_Change()
Dim txtSearchString As Variant
Dim strSQL As String
txtSearchString = Me!partNumber.Text
strSQL = "SELECT tbl_sparepart.PK_partName FROM tbl_sparePart"
strSQL = strSQL & "WHERE ((tbl_sparepart.PK_partNumber) = '" & txtSearchString & "*') "
Me!partName.RecordSource = strSQL
Me!partName.Requery
End Sub
anyone can help me?? i would be appreciate it.. Thnx in advanced