Solved

Search and replace in access dbase VB6

Posted on 2010-09-08
5
316 Views
Last Modified: 2012-05-10
Hello all,

I have a code that i use to save data in an Microsoft Access data base. Code bellow.

But now, i want to have a code that would search for the text in "txtNomDuProduit1"  (Name of a product in column 2 of my access db. and it would save all modification in the same row.

How can i do this please?

Thanks again for your help.
'Insert data in Microsoft Access Data Base
    Dim MyConn As ADODB.Connection
    Dim MyRecSet1 As New ADODB.Recordset

    Set MyConn = New ADODB.Connection
    MyConn.Open "Provider=Microsoft.ACE.OLEDB.12.0;;Data Source=" & Form4.txtBaseDe.Text
    MyRecSet1.Open "SELECT * FROM [Description produit] WHERE Produits='" & txtNomDuProduit1.Text & "'", MyConn, adOpenForwardOnly, adLockReadOnly


    If MyRecSet1.EOF Then
        MyRecSet1.close
        Set MyRecSet1 = MyConn.Execute( _
          "INSERT INTO [Description produit]  (Produits, Tube, Bouchon, Oring, Coût_unitaire, Par_tranche_de, Opération_1, Opération_2, Opération_3, Nombre_étape ) VALUES ( '" & _
          txtNomDuProduit1.Text & _
          "' , '" & txtTube1.Text & "' ,  '" & txtBouchon1.Text & "' ,'" & txtOring1.Text & "' ,'" & txtCout_unitaire.Text & "' ,'" & txtParTranche.Text & "' , '" & ComOpération1.Text & _
          "' , '" & ComOpération2.Text & "' ,'" & ComOpération3.Text & _
          "' , '" & ComNombreD.Text & "' )")
        MsgBox "Vos nouvelles quantités ont été enregistrées."  ', vbCritical, "Succesful adding"

Open in new window

product-db.jpg
0
Comment
Question by:Wilder1626
[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
  • 2
5 Comments
 
LVL 53

Expert Comment

by:Dhaest
ID: 33625508
For your update-query: which field is unique ? I assume you have a productID or something

MyConn.Execute( _
          "UPDATE [Description produit]  SET " & _
          " Produits = '" & txtNomDuProduit1.Text & "', " & _
          " Tube = '" & txtNomDuProduit1.Text & "', " & _
           "  ... " & _
           " where ProductID = " & YOURID_HERE
0
 
LVL 11

Author Comment

by:Wilder1626
ID: 33625595
ok, i will try this and let you know.

0
 
LVL 11

Author Comment

by:Wilder1626
ID: 33625628
I have try this but i have an syntaxe error

 Dim MyConn As ADODB.Connection
    Dim MyRecSet1 As New ADODB.Recordset

    Set MyConn = New ADODB.Connection
    MyConn.Open "Provider=Microsoft.ACE.OLEDB.12.0;;Data Source=" & Form4.txtBaseDe.Text
    MyRecSet1.Open "SELECT * FROM [Description produit] WHERE Produits='" & txtNomDuProduit1.Text & "'", MyConn, adOpenForwardOnly, adLockReadOnly

  MyConn.Execute ( _
   "Update [Description produit] WHERE  Produits = '" & txtNomDuProduit1.Text & "' ")
0
 
LVL 53

Accepted Solution

by:
Dhaest earned 500 total points
ID: 33625654
You didn't change any field ....

  MyConn.Execute ( _
   "Update [Description produit] SET tube = '" &  txtTube1.Text  & "' WHERE  Produits = '" & txtNomDuProduit1.Text & "' ")
0
 
LVL 11

Author Closing Comment

by:Wilder1626
ID: 33631915
Oh perfect.

Thanks
0

Featured Post

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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…
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…
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…
Suggested Courses
Course of the Month4 days, 21 hours left to enroll

636 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