FIND DATA

  • Thread starter Thread starter leungkong
  • Start date Start date
L

leungkong

hi,
i have set two textbox on a sheets, name "code" & "product name"
i want to set once i input "code" than use the code to search the product
name in product datebase, than copy to textbox "product name.
such as using vlookup in excel.
thanks so much
 
leungkong,
is the product database an access database?
Would you give some more details about it to help us volunteers understand
what you are trying to do?

Jeanette Cunningham
 
Hi Jeanette,
yes, product database is an access database.

actually, i want to make a invoice worksheet.
for the user, if the worksheet show
Code: 1 qty: 100 unit price: USD 2
it is not easy to understand what the goods is.

since the product name always need to change as per customer request
(customs problem, to avoid some word to save the tax)
so, i want to call the product name from the product database for reference.
product can be revised by user before update to invoice database
 
Use the AfterUpdate event procedure of the product code box to DLookup() the
product name and assign it to the text field you have for this purpose.

This kind of thing:

Private Sub ProductCode_AfterUpdate()
Dim strWhere As String
If Not IsNull(Me.ProductCode) Then
strWhere = "[ProductCode] = " & Me.ProductCode
Me.[Descrip] = DLookup("ProductName", "tblProduct", strWhere)
End If
End Sub

If ProductCode is a text field (not a Number field), you need extra quotes:
strWhere = "[ProductCode] = """ & Me.ProductCode & """"
Explanation:
http://allenbrowne.com/casu-17.html

For more help with DLookup(), see:
http://allenbrowne.com/casu-07.html
 
Thanks so much Allen

Allen Browne said:
Use the AfterUpdate event procedure of the product code box to DLookup() the
product name and assign it to the text field you have for this purpose.

This kind of thing:

Private Sub ProductCode_AfterUpdate()
Dim strWhere As String
If Not IsNull(Me.ProductCode) Then
strWhere = "[ProductCode] = " & Me.ProductCode
Me.[Descrip] = DLookup("ProductName", "tblProduct", strWhere)
End If
End Sub

If ProductCode is a text field (not a Number field), you need extra quotes:
strWhere = "[ProductCode] = """ & Me.ProductCode & """"
Explanation:
http://allenbrowne.com/casu-17.html

For more help with DLookup(), see:
http://allenbrowne.com/casu-07.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

leungkong said:
Hi Jeanette,
yes, product database is an access database.

actually, i want to make a invoice worksheet.
for the user, if the worksheet show
Code: 1 qty: 100 unit price: USD 2
it is not easy to understand what the goods is.

since the product name always need to change as per customer request
(customs problem, to avoid some word to save the tax)
so, i want to call the product name from the product database for
reference.
product can be revised by user before update to invoice database
 
Back
Top