UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> User-defined Type Noit Defined, Access 2013    
 
   
dzoker
post Jan 22 2020, 08:50 AM
Post#1



Posts: 457
Joined: 12-February 14



Hi There,

I tried to put together this function. It is suppose to open a new existing database based on the link in tblDatabases "DatabaseLink" where the LinkID = ButtonName. I'm very new when it comes to Functions so be gentle please uarulez2.gif Im getting this error when I compile.

CODE
Public Function OpenDtb(LinkID As Long, ButtonName As Text)
    Dim Link As String
    Dim accapp As Access.Application
    Link = DLookup("[DatabaseLink]", "tblDatabases", [LinkID] = ButtonName)
    Set accapp = New Access.Application
    accapp.OpenCurrentDatabase Link
End Function


Any help please?
Go to the top of the page
 
cheekybuddha
post Jan 22 2020, 09:03 AM
Post#2


UtterAccess Moderator
Posts: 12,268
Joined: 6-December 03
From: Telegraph Hill


You need to create the criteria as a string - it's essentially an SQL 'WHERE' clause.

I'm guessing ButtonName is a string, so try something like:
CODE
' ...
    Link = DLookup("[DatabaseLink]", "tblDatabases", "[LinkID] = '" & ButtonName & "'")
' ...


hth,

d

--------------------


Regards,

David Marten
Go to the top of the page
 
dzoker
post Jan 22 2020, 09:24 AM
Post#3



Posts: 457
Joined: 12-February 14



Ok Got it,

Thank you cheekybuddha for opening my eyes :-)

CODE
Public Function OpenDtb(ButtonName As Integer)
    Dim Link As String
    Dim accapp As Access.Application
    Link = DLookup("[DatabaseLink]", "tblDatabases", "[LinkID] = " & ButtonName)
    Set accapp = New Access.Application
    accapp.OpenCurrentDatabase Link
End Function
Go to the top of the page
 
cheekybuddha
post Jan 22 2020, 09:36 AM
Post#4


UtterAccess Moderator
Posts: 12,268
Joined: 6-December 03
From: Telegraph Hill


Nice! thumbup.gif

So, ButtonName is a numeric field?

--------------------


Regards,

David Marten
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    20th February 2020 - 01:03 PM