Solved

Search question

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

762 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

21 Experts available now in Live!

Get 1:1 Help Now