macro qui pose probleme

tonychange

XLDnaute Occasionnel
bonjour,

j'ai un probleme avec mon code je souhaite effectuser une mise a jour depuis une base de données access.
lorsque j'ouvre mon fichier ou que je lance ma macro j'ai une erreur d'éxécution "1004" (la méthode 'range de l'objet '_global' a échoué
Set rg = Range("Database")

merci pour votre aide

ci dessous mon code

Sub UpdatePage()
'get data from test database


'Macro Purpose: To retrieve a recordset from a database (via an SQL query) and place
' it in the supplied worksheet range
'NOTE : Requires a reference to "Microsoft ActiveX Data Objects 2.x Library"
' (Developed with reference to version 2.0 of the above)
Application.ScreenUpdating = False
Dim rg As Range
'set connection paths
Set rg = Range("Database")
glob_DBPath = rg.Value
'check if apth is correct
glob_sConnect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & rg.Value & ";"
Set rg = Range("Movie")
Dim strSql As String
strSql = "SELECT TOP 13 tblMediaViewed.Comments,"" "","" "","" "","" "", COUNT(tblMediaViewed.Comments) "
strSql = strSql + "FROM tblMediaViewed "
strSql = strSql + "GROUP BY tblMediaViewed.Comments "
strSql = strSql + "ORDER BY COUNT(tblMediaViewed.Comments) DESC, tblMediaViewed.Comments;"


'Open connection to the database
cnt.Open glob_sConnect
'Open recordset based on tblMediaViewed table
rst.Open strSql, cnt
'copy result to range
rg.CopyFromRecordset rst
rst.Close
 

Membres actuellement en ligne

Aucun membre en ligne actuellement.

Statistiques des forums

Discussions
312 493
Messages
2 088 956
Membres
103 990
dernier inscrit
lamiadebz