By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,264 Members | 1,100 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,264 IT Pros & Developers. It's quick & easy.

Currentdb doesn't work with adp file

P: n/a
ray
I am creating a new module in an existing ADP (new ground for me, have
only ever used mdb's before).

The module is a copy of some Albert Kallal code posted a while ago,
which searches modules.

It fails saying 'Object Variable or With Block not set'. It seems that
the dbxxx object reference can't be set. When I put my cursor over it,
it shows dbxxx=Nothing.

There is an explicit reference set to DAO 3.6 Object Library in
References. The project compiles OK. I have tried "Set dbxxx =
DBEngine(0)(0)" and "Set dbxxx = Currentdb()" and nothing seems to
work. Any ideas please?

Ray
Sub ModSearch()
Dim dbxxx As DAO.Database
Dim Doc As Document
Dim mdl As Module
Dim occFound As Integer

strSearch = InputBox("Search for", "Search")
If strSearch = "" Then Exit Sub

Set dbxxx = CurrentDb

For Each Doc In dbxxx.Containers("Modules").Documents <<<< fails here
DoCmd.OpenModule Doc.Name
Set mdl = Modules(Doc.Name)
lngCount = lngCount + mdl.CountOfLines
' search
For i = 1 To lngCount
strOneLine = mdl.Lines(i, 1)
sPtr = InStr(strOneLine, strSearch)
If sPtr 0 Then
occFound = occFound + 1
End If
Next i
Set mdl = Nothing
DoCmd.Close acModule, Doc.Name
Next

MsgBox "Found " & occFound & " lines containing " & strSearch

End Sub

Aug 30 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
why are you using DAO with an ADP? Shouldn't you be using ADO instead?

Aug 30 '06 #2

P: n/a
ray
thanks Piet,
The existing app has a refererence to DAO and has been working
successfully in a distributed environment for some years.

And the Help says:

Note In Microsoft Access the CurrentDb method establishes a hidden
reference to the Microsoft DAO 3.6 Object Library in a Microsoft Access
database (.mdb). If you want to use the CurrentDb method in an Access
project (.adp) you must set a permanent reference to the DAO 3.6 Object
library in the Microsoft Visual Basic Editor.

So I think it's ok to do it the way I want to do it. But it just
doesn't work?!
Ray
pi********@hotmail.com wrote:
why are you using DAO with an ADP? Shouldn't you be using ADO instead?
Aug 30 '06 #3

P: n/a
shows ya what I know!!! <g>

Maybe use GetReferenceFromFile? and load that way? either that or maybe
use late binding?

Aug 30 '06 #4

P: n/a
ray
Well, anyway that's what the Help says. I have since found a thread
where Michka says point blank that it doesn't work (which seems to be
the case).

I have also since found another thread where one of our other Access
community genii has posted a handful of lines of code which does the
same thing under ADO, and it works like a charm.

Thanks for your suggestions,

Ray
pi********@hotmail.com wrote:
shows ya what I know!!! <g>

Maybe use GetReferenceFromFile? and load that way? either that or maybe
use late binding?
Aug 30 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.