Update method in VB6 not working properly 
Author Message
 Update method in VB6 not working properly

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



Sat, 14 Sep 2002 03:00:00 GMT  
 Update method in VB6 not working properly
Hi Ivan,

Can you post some code?

--
Andrew Grillage
http://vbdata.iwarp.com


Quote:
> 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



Sat, 14 Sep 2002 03:00:00 GMT  
 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



Sat, 14 Sep 2002 03:00:00 GMT  
 Update method in VB6 not working properly
Its so {*filter*}y long since I looked at DAO code. I can only suggest posting to
the dao newsgroup which might be more appropriate.

--
Andrew Grillage
http://www.*-*-*.com/


Quote:
> 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



> > Hi Ivan,

> > Can you post some code?

> > --
> > Andrew Grillage
> > http://www.*-*-*.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



Sun, 15 Sep 2002 03:00:00 GMT  
 Update method in VB6 not working properly
Long time since I used DAO code ...
bit blurry on it now but I used

replace the line in your code (as below)
dbMWS.CommitTrans dbForceOSFlush

with the following

dbMWS.CommitTrans
DBEngine.Idle dbRefreshCache
' <help file info - under "IDLE">
' forces any pending writes to .mdb files,
' and refreshes memory with the most
' current data from the .mdb file.

hope this helps

 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Thanks, John

reply to:

City of Sails
Devonport, Auckland
New Zealand



Tue, 17 Sep 2002 03:00:00 GMT  
 Update method in VB6 not working properly
Hi John,

Thanks for your suggestion. I'll try it out and see if it works.

Ivan


Quote:
> Long time since I used DAO code ...
> bit blurry on it now but I used

> replace the line in your code (as below)
> dbMWS.CommitTrans dbForceOSFlush

> with the following

> dbMWS.CommitTrans
> DBEngine.Idle dbRefreshCache
> ' <help file info - under "IDLE">
> ' forces any pending writes to .mdb files,
> ' and refreshes memory with the most
> ' current data from the .mdb file.

> hope this helps

>  -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
> Thanks, John

> reply to:

> City of Sails
> Devonport, Auckland
> New Zealand



Sat, 21 Sep 2002 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Update method in VB6 not working properly

2. Update not working properly

3. VB6 Inet....Does not work Properly

4. CDO update method works W2K but not in NT4

5. Update method not working

6. Update method not working

7. Addnew and update method in ADOCE not working ?

8. Select method doesn't work properly

9. Cannot make AddNew method work properly.

10. Cannot make AddNew method work properly.

11. Begintrans method of Connection object does not function properly in .Net

12. Referrer property not being set properly when using the Navigate method of the WebBrowser control

 

 
Powered by phpBB® Forum Software