
Update method in VB6 not working properly
Hi Andrew,
Here is the complete function which I'm calling:
Private Function SaveIncident() As Long
On Error GoTo trap_err
Set dbMDB = dbMWS.OpenDatabase(ProjectPath & dbName, False, False,
";pwd=" & dbPass)
Set INCID = dbMDB.OpenRecordset("Records - Incident", dbOpenTable)
On Error GoTo trxtrap_err
dbMWS.BeginTrans
With INCID
.LockEdits = True
.AddNew
!site_id = CInt(WrkSite)
!incident_type =
CInt(incident_type.ItemData(incident_type.ListIndex))
!ref_id = CInt(ref_id.ItemData(ref_id.ListIndex))
!audit_id = 0
!rec_line_id = Val(frmGeneralClose_Details.rec_line_id)
!plan_id = 0
!doc_id = 0
!desc = desc
!Date = Format(incident_date.Value, "Short Date")
!originator = originator
!targeted = targeted
!reference = reference
!planned_date = Format(planned_date.Value, "Short Date")
.Update
.LockEdits = False
.Bookmark = .LastModified
SaveIncident = !incident_id
.Close
End With
dbMWS.CommitTrans dbForceOSFlush
On Error GoTo trap_err
trap_err_exit:
If Not dbMDB Is Nothing Then
dbMDB.Close
Set dbMDB = Nothing
End If
Exit Function
trxtrap_err:
dbMWS.Rollback
trap_err:
SaveIncident = 0
MsgBox Err.Description
Resume trap_err_exit
End Function
Quote:
> Hi Ivan,
> Can you post some code?
> --
> Andrew Grillage
> http://vbdata.iwarp.com
> > Hi all,
> > I have quite a weird situation here. I have a VB6 (sp3) application
which
> > updates an Access 97 database using DAO. In a particular instance, when
I
> > update the table I return its autonumber (which is correct), but when
> > immediately after I run an SQL statement to preview the report (always
in
> > VB), there is no data.
> > I have debugged the code a million times and it's ok, because the same
> > function is used elsewhere in the application. I have also monitored the
> the
> > Access table. It looks like the record is not inserted immediately in
the
> > table. I have included the .committrans dbforceosflush but it doesn't
> work.
> > Does anybody know what is happening and what could be the solution?
> > Tks all,
> > Ivan