What am I doing wrong?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



I have little knowledge of databases and am struggling with several problems that are not shown in
any of the texts that I have. I have VB6 SP6 enterprise edition, XP home edition and using DAO 3.6.

I have tried to use the following to update/edit a single, existing record, but it does not always
act on the correct record. My database has 2 records in a single table (now) because I am beginning
to code this program. This table has company records. A second table exists, but is not in use
yet. It will list company transaction details (when I get that far) and connect to each respective
company.

Other than using SQL which is my next try, how do I make the Edit/Update act upon the correct
(displayed) record? I know that in SQL I would include WHERE CompanyID =
FrmMain.LblCoIDNbr.Caption. To me, Update means the user revises a single, existing record, clicks
the "Update" command and the displayed record is updated in the database. Can you help me to
accomplish that?

Can anyone recommend an excellent tutorial text that shows VB6 DAO database example code? The few
texts that I have are 90% ADO and for some reason I do not like ADO. With DAO being around since
VB3, I would think there are dozens of tutorial texts on VB6 DAO.

Thank you,
Jim Y

============================================
Public Sub UpdateClient()

Dim rstCompany As Recordset

On Error GoTo ErrHandler

Set rstCompany = gdbDrvrExp.OpenRecordset("tblCompany")

Workspaces(0).BeginTrans
rstCompany.Edit
rstCompany.Fields("CompanyName") = FrmMain.Text2(0).Text
rstCompany.Fields("CoAddress") = FrmMain.Text2(1).Text
rstCompany.Fields("CoCity") = FrmMain.Text2(2).Text
rstCompany.Fields("CoState") = FrmMain.Text2(3).Text
rstCompany.Fields("CoZIP") = FrmMain.Text2(4).Text
rstCompany.Fields("CoPhone1") = FrmMain.Text2(5).Text
rstCompany.Fields("CoPhone2") = FrmMain.Text2(6).Text
rstCompany.Fields("CoFAX") = FrmMain.Text2(7).Text

rstCompany.Update
Workspaces(0).CommitTrans

rstCompany.Close
Set rstCompany = Nothing

Exit Sub


.



Relevant Pages

  • Re: Problem with ADO net 2.0
    ... Dim ds As New dbprovaDataSet ... And if you want to make it even quicker you use VB6 instead of VB.Net,, as ... database as this is native to .Net ...
    (microsoft.public.dotnet.languages.vb)
  • Re: SQL database for use with VB6
    ... distribution that enables VB6 to access the Microsoft Jet Database. ... reason you stated. ...
    (microsoft.public.vb.general.discussion)
  • Re: Im very confused about the different databases!
    ... There's DAO, ADO, ADO.NET, Jet, SQL, SQL Server ... What database & version comes with VB6 LE? ... What is the most current database that I can use with VB6 LE? ... Why isn't Jet or whatever VB6 LE uses listed in Add-Remove Programs? ...
    (microsoft.public.vb.general.discussion)
  • Re: VB.Net and database
    ... > I was looking at database connection with VB.net and seeing what the ... > to use code a databse just controls. ... VB.Net is not VB6++. ... VB macro language built into Microsoft products are very similar and knowing ...
    (microsoft.public.dotnet.languages.vb)
  • Re: VBA CODE - ADODB
    ... i have been looking at vb6 and ado and dao. ... i have looked at the coding for adodb - and it does ... > Dim dbShop As Database 'declare database object ... > Dim rsShop As Recordset 'declare recordset object ...
    (microsoft.public.vb.general.discussion)