DLookup - connect to db

Stevenn

Active Member
Joined
Feb 8, 2012
Messages
259
I've tried to use DLookup in Excel, but how do I connect to my database before i use the function?

I've tried

Code:
Private Sub HentData()
    MsgBox Access.Application.DLookup("[Name]", "Persons", "[Id] = 2")
End Sub

but i guess it wont work before i choose which database i will use.
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
I see from earlier posts you've already been given the basics of connection to access from excel

Why don't you reuse that

The DLookup function seems to be smarter when I just want 1 post based on an unique Id :)

I've tried to use basic access connection, but I can't use "WHERE Id = n LIMIT 1" in my SQL query
 
Upvote 0
The D (Domain) functions in Excel are not the same as the D functions in Access

"WHERE Id = n LIMIT 1" in my SQL query

"WHERE Id = " & n & " LIMIT 1"
 
Upvote 0

Forum statistics

Threads
1,214,943
Messages
6,122,380
Members
449,080
Latest member
Armadillos

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top