Set db = OpenDatabase(StringOfLocation, True) doesn't work

so10070

Registered User.
Local time
Today, 20:23
Joined
Aug 18, 2016
Messages
53
In one of my application doesn't work this statement. In the other I have no problem at all. It gives the error "Sub or function not defined". :mad:
Code:
        LocationNewApplication = DLookup("VersionNewAppLocation", "tblVersieProgramma") & "\" & CurrentProject.Name
        Set db = OpenDatabase(VersionNewAppLocation, True)
        Set rs = db.OpenRecordset("tblVersieLokaal")
 
Some errors:
Code:
LocationNewApplication = DLookup("VersionNewAppLocation", "tblVersieProgramma") & "\" & CurrentProject.Name
        Set db = OpenDatabase(VersionNewAppLocation, True)
        Set rs = db.OpenRecordset("tblVersieLokaal")

The DLookup syntax is
DLookup(field name, table or query name, filter criteria)
This is probably OK - add a debug.print line to check output

The OpenDatabase syntax is:
expression.OpenDatabase(Name, Options, ReadOnly, Connect)

So this should be something like
Code:
Set db = DBEngine(0).OpenDatabase([COLOR="red"]"[/COLOR]VersionNewAppLocation[COLOR="Red"]", ,[/COLOR]True)

The recordset line should be something like
Code:
Set rs = db.OpenRecordset("tblVersieLokaal", OpenDynaset)

Have you defined db and rs earlier in your code? If not do so.
 
It works! :)
But I have to use instead of OpenDynaset, 2. That works.
 

Users who are viewing this thread

Back
Top Bottom