Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dlookup, Dcount

Status
Not open for further replies.

Djbell

IS-IT--Management
Apr 22, 2002
175
GB
I have an Access 97 database that uses the dlookup and the dcount functions, but they will not compile in Windows 95, but they work OK in Windows 2000.

Does anyone know of a way round this or alternatives to these that work in both 95 and 2000.

Regards

Djbell
 
The problem is bound to be references. Open up the module and click Tools|References. There should be one that's marked missing. Write down the name. Unclick it. Close the dialog and open it again. Find it in the list click it. Close the dialog. Recompile.

Let us know if that doesn't do the trick.

Jeremy =============
Jeremy Wallace
Designing, Developing, and Deploying Access Databases Since 1995

Take a look at the Developers' section of the site for some helpful fundamentals.
 
Maybe you're missing a reference required to make these functions work? Anyway, off the top of my head, here are some alternative functions:

Code:
Function fctnDCount(Expr As String, Domain As String, Optional Criteria As String) As Long
On Error GoTo Err_fctnDCount
    Dim rst As DAO.Recordset
    If Len(Criteria) > 0 Then
        Set rst = DBEngine(0)(0).OpenRecordset("SELECT COUNT(" & Expr & ") AS Counter FROM " & Domain & " WHERE " & Criteria & ";")
    Else
        Set rst = DBEngine(0)(0).OpenRecordset("SELECT COUNT(" & Expr & ") AS Counter FROM " & Domain & ";")
    End If
    rst.MoveFirst
    fctnDCount = rst!Counter
    rst.Close

Exit_fctnDCount:
    Exit Function
Err_fctnDCount:
    MsgBox Err.Number & ": " & Err.Description, vbExclamation
    Resume Exit_fctnDCount
End Function

Function fctnDLookup(Expr As String, Domain As String, Optional Criteria As String) As Variant
On Error GoTo Err_fctnDLookup
    Dim rst As DAO.Recordset
    If Len(Criteria) > 0 Then
        Set rst = DBEngine(0)(0).OpenRecordset("SELECT " & Expr & " AS Lookup FROM " & Domain & " WHERE " & Criteria & ";")
    Else
        Set rst = DBEngine(0)(0).OpenRecordset("SELECT " & Expr & " AS Lookup FROM " & Domain & ";")
    End If
    If Not rst.EOF Then
        rst.MoveFirst
        fctnDLookup = rst!Lookup
    Else
        fctnDLookup = Null
    End If
    rst.Close

Exit_fctnDLookup:
    Exit Function
Err_fctnDLookup:
    MsgBox Err.Number & ": " & Err.Description, vbExclamation
    Resume Exit_fctnDLookup
End Function
[pc2]
 
Hi Jeremy

I have no references that are missing.

I have the following references installed:-

Visual Basic for Applications
Microsoft Access 8.0 Object Library
OLE Automation
Microsoft DAO 3.6 Object Library
Visual Basic for Applications Extensibility

Should I have any other ones ticked for use with Windows 95

The error message is:-

Compile error in hidden module.

Regards

Djbell
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top