admin管理员组文章数量:1302275
I'm using a Excel 2016 with Database Access 2016 too. At home the code run perfectly, but in my office the same file getting a error in this line:
varX = DLookup("[Código]", "Campanha", "[Cod Produto] = " & EntradaBD.Fields("Cod Produto").Value & "")
Interesting when I open manually DB file the error is gone, but when BD is open programmatically I get this error: 2950 - reserved error. My BD open normally, and even though I have placed file in a trusted place.
Thanks for read this.
UPDATE: When i arrived at home, same problem now: 2950 reserved error . But his line worked yesterday and i dont edit file.
UPDATE2: I realized that Dlookup only works when the database file is open, that is, with MSAccess on the screen. All other DB access functions work with the file closed, but DlookUp insists on error 2950, what could it be?
UPDATE3:
Private Sub cbgrupo_Change()
Dim fonteBD As String
Dim varX As Variant
Set EntradaBD = New ADODB.Recordset
ConectaAccess
If Me.cbgrupo.Value = "TODOS" Then
fonteBD = "Select * FROM [BancoDados] WHERE [Grupo] is not null ORDER BY [Cod Produto]"
Else
fonteBD = "Select * FROM [BancoDados] WHERE [Grupo] = '" & Me.cbgrupo.Value & "' ORDER BY [Cod Produto]"
End If
EntradaBD.Open fonteBD, conectabd, adOpenKeyset, adLockReadOnly
If Not (EntradaBD.EOF And EntradaBD.BOF) Then
EntradaBD.MoveFirst
Do Until EntradaBD.EOF = True
varX = DLookup("[Código]", "Campanha", "[Cod Produto] = " & EntradaBD.Fields("Cod Produto").Value)
If IsNull(varX) Then
Me.ListBox1.AddItem EntradaBD.Fields("Cod Produto").Value
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 1) = EntradaBD.Fields("Produto").Value
End If
EntradaBD.MoveNext
Loop
End If
If Not EntradaBD Is Nothing Then EntradaBD.Close
'fecha a conexão com o BD
DesconectaAccess
本文标签: excelVBA DLookUp returns error 2950 reserved errorStack Overflow
版权声明:本文标题:excel - VBA DLookUp returns error 2950: reserved error - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741711984a2393897.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论