Solved

Search question

Posted on 2002-03-19
3
142 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 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VBA Word macro - how to get characters after the searched for string 5 68
using Access 8 58
Access query that references subform 5 43
vb6 connector to SQL Server 2 34
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…

911 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now