DLookup seems to be nice comfy function to access any database data quickly from anywhere.
However there remain two problems:
1) DLookups (and the DSum, etc. counterparts) are supposed to be slow. I keep reading this everywhere - dlookup is the slowest data access possible.... is this true?
2) Before getting data via a dlookup, the dlookup must be compared to IsNull to avoid the error of assigning a Null value to a variable or field. So every single DLookup ends up being two DLookups (One check for IsNull and Another One for the variable assignment if not(isnull())). I prepared a function like this to work around this problem:
Function secureDLookup(Expr As String, Domain As String, Optional Criteria As String) As String
If IsNull(DLookup(Expr, Domain, Criteria)) Then
secureDLookup = ""
Else
secureDLookup = DLookup(Expr, Domain, Criteria)
End If
End Function
Regarding the Speed problem, my question: Does it make sense to replace the DLookup inside the above function with an own VBA Recordset lookup (currentdb.OpenRecordSource, FindFirst, etc...) ??? Again I *read*, accessing data via recordsets is supposed to be the fastest access?
Related question: How fast is DoCmd.RunSql in comparison ??
Another related question: How do I *prepare* an access application for later use with an sql server? I guess this is a more complicated issue, isnt it?
Regards
waldemar
However there remain two problems:
1) DLookups (and the DSum, etc. counterparts) are supposed to be slow. I keep reading this everywhere - dlookup is the slowest data access possible.... is this true?
2) Before getting data via a dlookup, the dlookup must be compared to IsNull to avoid the error of assigning a Null value to a variable or field. So every single DLookup ends up being two DLookups (One check for IsNull and Another One for the variable assignment if not(isnull())). I prepared a function like this to work around this problem:
Function secureDLookup(Expr As String, Domain As String, Optional Criteria As String) As String
If IsNull(DLookup(Expr, Domain, Criteria)) Then
secureDLookup = ""
Else
secureDLookup = DLookup(Expr, Domain, Criteria)
End If
End Function
Regarding the Speed problem, my question: Does it make sense to replace the DLookup inside the above function with an own VBA Recordset lookup (currentdb.OpenRecordSource, FindFirst, etc...) ??? Again I *read*, accessing data via recordsets is supposed to be the fastest access?
Related question: How fast is DoCmd.RunSql in comparison ??
Another related question: How do I *prepare* an access application for later use with an sql server? I guess this is a more complicated issue, isnt it?
Regards
waldemar