Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Search question

Posted on 2002-03-19
3
Medium Priority
?
149 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
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 600 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses

963 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