Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB 5 updaing DBGrid

Status
Not open for further replies.

ck1999

Technical User
Dec 2, 2004
784
0
0
US
I have a form that has a dbgrid on it. I then have a button to archive the record. Once archived (Moved to another databse). I then try to delete the record using and adodb connection. (By the way everything is working great both the archiving and deletion)

However, once deleted the dbgrid is not updated. After deleting the record I use
Code:
    Datalisting.Recordset.Requery
    DoEvents
    Datalisting.Refresh

The DBGrid is unchanged. datalisting is the source for the dbgrid. If I close the form and reopen the record has been removed.

However, If I archive 1 record then a second. The 1st will be removed but not the second. Then I archive another then the 2nd record is removed from the grid but not the third.



Any Ideas.

Thanks

ck1999
 
I assume that you mean DataGrid and not dbGrid. dbGrid is a DAO control.

It may be a synchronization problem. Try refreshing the cache.
Code:
Dim je As New JRO.JetEngine

je.RefreshCache cnn

Datalisting.Recordset.Requery
[blue]etc.[/blue]
Where "cnn" is your connection object.

You should also note that the ADO data control can be a bit flakey. You can connect a more garden-variety ADO recordset to a DataGrid and I have found that's a less problematic approach.
 
I started this about 8 months ago and have went back to it to finish it. That being said I know just enough VB to hurt something.

What I have done is added a data control to the form (Datalisting)
use this code on form load
Code:
    Datalisting.DatabaseName = gsdatabase
    
    'gsRecordSource is a global string that needs
    'to be set by the sub routine that loads this form
    Datalisting.RecordSource = strQuery
    Datalisting.RecordsetType = 1     'dynaset
    Datalisting.Options = 0
    Datalisting.Refresh

Then i have added a dbgrid control to the form. (grdDatagrid)
datasource property for grddatagrid is datalisting.

So I wrote all this to say what would be my conn

Also, I tried using your code where I was deleting the record but got "user-defined type not defined" error. I added the reference "Jet Expression service type" but this did not help.

ck1999
 
I added the reference "Microsoft Jet" and I did not get the error yet it did not work.

ck1999
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top