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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Datagrid - can't REFRESH!!!!

Status
Not open for further replies.

LiLgUrL

Technical User
Feb 9, 2003
59
CA
it's my first time to use datagrid and im still trying to discover some of its magic - if we can call it that way :)

ok - i am using a combo box (contains list of filenames - which are in excel format) and once i selected one... it will be imported into a temporary table - and from there it will also be displayed in a datagrid.

everytime i select a filename... before it will import the contents of the excel it will clear my temp table first...

Code:
Set rs = New ADODB.Recordset
    With rs
        .Open "DELETE * FROM Temp_Table", conn, adOpenForwardOnly, adLockPessimistic
    End With
    Adodc1.Recordset.Requery
    Adodc1.Refresh
    dgrdMain.Refresh

and that's my problem... i used .Refresh but how come my datagrid is not being updated. I want it in a way that every time i select a filename - and once my Temp_Table is cleared my datagrid should also be cleared immediately without closing and opening the form just to have it refreshed...
 
i got it!

Code:
    Set rs = New ADODB.Recordset
    With rs
        .Open "Select * FROM Temp_BOM", conn, adOpenForwardOnly, adLockPessimistic
        
        While .EOF = False
        .Delete
        .MoveNext
        Wend
        rs.Requery
    End With
    
    Adodc1.Refresh
    FrmRegBOM.Refresh
    dgrdMain.Refresh

But i wonder why it's not working with

Code:
  .Open "DELETE * FROM Temp_Table", conn, adOpenForwardOnly, adLockPessimistic
 
Hi LiLgUrL,

The reason the following code does not work is that you can not delete records while opening a recordset.

.Open "DELETE * FROM Temp_Table", conn, adOpenForwardOnly, adLockPessimistic

You could however do what you want with the connection object you are using:

conn.Execute "DELETE * FROM Temp_Table"

Hope that helps,
-GS
 
garths2 it;s you again! Thanks for answering my questions I am really learning a lot from you and from this forum of course... You're my hero [thumbsup]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top