Dcount "Type mismatch" error help

Taurus05

Registered User.
Local time
Today, 00:33
Joined
Mar 29, 2005
Messages
31
Hi,

I'm trying to use 2 criterias for this dcount function but I get "type mismatch" error. What I want to do here is, if the model (from model and to model) is not existing, activate a new form). Any help will be appreciated. Other alternative methods are welcome as well.

Thank you.


Private Sub REF_Enter()
Dim OUTx As Integer
Dim INy As Integer

OUTx = DCount("*", "STDCONVOUT", "[FROMMODEL]='" & Me.[FROMMODEL] & "'" And "[TOMODEL]='" & Me.[REQUESTMODEL] & "'")
INy = DCount("*", "STDCONVIN", "[STDCONVIN]![FROMMODEL]='" & Me.[FROMMODEL] & "'" And "[STDCONVIN]![TOMODEL]='" & Me.[REQUESTMODEL] & "'")
'OUTx = DCount("[PARTNUM]", "STDCONVOUT", "[STDCONVOUT]![FROMMODEL]='" & Me.[FROMMODEL] & "'")

If (OUTx = 0) And (INy = 0) Then
If MsgBox("This is a new model. Add this model?", vbOKCancel, "Error!") = vbOK Then
DoCmd.OpenForm "AddConvModel", acNormal
End If
End If
End Sub
 
Try one DLookUp at a time to try to show which one throwing up an error.

The "AND" is not in quotation marks

OUTx = DCount("*", "STDCONVOUT", "[FROMMODEL]='" & Me.[FROMMODEL] & "'" & " And [TOMODEL]='" & Me.[REQUESTMODEL] & "'")

INy = DCount("*", "STDCONVIN", "[STDCONVIN]![FROMMODEL]='" & Me.[FROMMODEL] & "'" & " And [STDCONVIN]![TOMODEL]='" & Me.[REQUESTMODEL] & "'")

MsgBox OUTx
MsgBox INy
 
Thanks Oldsoftboss. It works! I'm missing the "&" in my dcount function. I was about to give up dcount() function. lol.
 

Users who are viewing this thread

Back
Top Bottom