Solved

Search question

Posted on 2002-03-19
3
145 Views
Last Modified: 2010-05-02
i have a form with 3 textboxes across called

"Product description", "UnitPrice" and "Discount"

i have coppied these down in a control array ie

txtProductDescription(1)
txtProductDescription(2)

etc for each of the 3, what i would like to know is whenever i type in a product in the product description textbox it searches the "Products" table in my Access database and updates the other fields across with the appropriate information. How could i do this? and make it work for each txtbox down?

i am using the standard data control

thanks for any help!

0
Comment
Question by:digitaldestruction66
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 1

Expert Comment

by:alaplume
ID: 6880741
The control array will share a change event and provide and index telling you what control has focus.
0
 
LVL 39

Accepted Solution

by:
appari earned 200 total points
ID: 6881554
something like this in validate event

Private Sub txtProductDescription_Validate(Index As Integer, Cancel As Boolean)
If txtProductDescription(index)<> "" Then
   '**** Get Data from tables
  strSQL=" Select * from Table where roduct=" & txtProductDescription(index)
  'create recordset using ur connection
  if not recordset.eof then
      unitprice(index)=recordset("unitprice")
      discount(index)=recordset("discount")

  else
      msgbox "no data found for this product"
      cancel=true
  endif
End If
End Sub
0
 

Author Comment

by:digitaldestruction66
ID: 6883127
thanks appari, i modified it a bit but it doesn't seem to compile, can you help please? I have upped the points to 200. The code is below

Private Sub txtProductID_Validate(Index As Integer, Cancel As Boolean)
Dim RS As Recordset
Dim strSQL As String
    If txtProductID(Index) <> "" Then
  '**** Get Data from tables
  datProducts.RecordSource = strSQL
 strSQL = " Select * from Products where ProductName=" & txtProductID(Index)
 'create recordset using ur connection
 If Not RS.EOF Then
     txtUnitPrice(Index) = RS("UnitPrice")
     'txtDiscount(Index) = RS("discount")

 Else
     MsgBox "no data found for this product"
     Cancel = True
 End If
End If
End Sub

i am a beginner at this so an explanation would be excellent, the more help i get the more points you get!

cheers

DD66
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question