DCount to decide (1 Viewer)

ECEK

Registered User.
Local time
Today, 20:17
Joined
Dec 19, 2012
Messages
717
Im struggling to get this to create a message for the user.

I have an import spec that imports my data to a holding table, checks that the data isn't already in the main table then adds if not.

Code:
Private Sub Command0_Click()
    DoCmd.RunSavedImportExport "Import-AllocatedCash"
    
    ' I now have a query based on a joined query between the Main table and qryImportCount
    
    Dim RecCount             As Long
    RecCount = DCount("*", "qryImportCount")
    
    If ReCount > 0 Then
    MsgBox " Not Imported"
    Else
    MsgBox " Imported"
    
    DoCmd.OpenQuery "apdImportToAllocatedCash"
    End If
End Sub

Regardless of whether the data is or isn't in my Main table, I am getting MsgBox "Imported" as my result.

I shall endeavour to study DCount but maybe you guys can shed a quick beacon of light on this for me?
 

moke123

AWF VIP
Local time
Today, 15:17
Joined
Jan 11, 2013
Messages
3,915
I'm gonna guess you don't have Option Explicit declared at the top of your module.
Code:
    Dim RecCount             As Long
    RecCount = DCount("*", "qryImportCount")
    
    If ReCount > 0 Then

Dim RecCount
RecCount = DCount

If ReCount > 0

Spelling counts!
 

Ranman256

Well-known member
Local time
Today, 15:17
Joined
Apr 9, 2015
Messages
4,337
using OPTION EXPLICIT will catch these errors the eye may not.
 

ECEK

Registered User.
Local time
Today, 20:17
Joined
Dec 19, 2012
Messages
717
Thanks Guys. Schoolboy error!
 

Users who are viewing this thread

Top Bottom