August 13, 2004 at 7:53 am
Hello All:
I'm working on a converted access .adp and I just found out that domain aggregate functions, in particular Dlookup, are not available. Does anyone have a good approach to resolve this? Is there another function I could use or should I write a new function to replace it?
Any help is greatly appreciated.
Thanks, Cleech
August 16, 2004 at 2:08 am
Hi Cleech,
Try using a sub-query instead. For Example, in Access a query could look like:
Can be represented in SQL Server as:
Can be represented in T-SQL as:
Hope this helps!
August 16, 2004 at 2:35 am
Create your own Dlookup function.
Something like this:
Public Function fDlookup(sField As String, sTable As String, sCriteria As String) As Variant
On Error GoTo fDlookup_Error
Dim rst As New ADODB.Recordset
Dim sSQL As String
fDlookup = ""
sSQL = "SELECT " & sField & " " & _
"FROM " & sTable & " " & _
"WHERE " & sCriteria
rst.Open sSQL, CurrentProject.Connection, adOpenForwardOnly, adLockReadOnly
If Not rst.BOF Then
fDlookup = Trim$(rst(sField))
End If
fDlookup_Exit:
If rst.State = adStateOpen Then rst.Close
Set rst = Nothing
Exit Function
fDlookup_Error:
MsgBox Err.Description, vbInformation, "Function fDlookup"
fDlookup = Null
Resume fDlookup_Exit
End Function
Anders Dæmroen
epsilon.no
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply