What am I doing wrong?
- From: "Jim Y" <j.s.yablonsky@xxxxxxxxxxxxxx>
- Date: Sun, 30 Apr 2006 23:24:31 GMT
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
.
- Follow-Ups:
- Re: What am I doing wrong?
- From: Jim Y
- Re: What am I doing wrong?
- From: argusy
- Re: What am I doing wrong?
- Next by Date: Re: What am I doing wrong?
- Next by thread: Re: What am I doing wrong?
- Index(es):
Relevant Pages
|