The result is already numeric.
If you need further, cast it to Int() function
Select Int(Count(field)) As IntCount ....
I = "SELECT Int(Count([Email])) as [ResultFm].[nnum] FROM [" & dest & "]" & _
" WHERE [Language] <> 'X' ORDER BY [LastName];"
Yiu lack a recordset for that to work:
I= currentdb.openrecordset("select count(email)....")(0)
I = "SELECT Int(Count([Email])) as [ResultFm].[nnum] FROM [" & dest & "]" & _
" WHERE [Language] <> 'X' ORDER BY [LastName];
I = DCount("Email","[" & dest & "]")
Me.nnum = I
Forms!ResultFm.nnum=I
Me.nnum=DCount("Email","[" & dest & "]")
Yes but if I omit the where clause then how can I impose the Language <> 'X' filter?Your code makes little sense to me :
Code:I = "SELECT Int(Count([Email])) as [ResultFm].[nnum] FROM [" & dest & "]" & _ " WHERE [Language] <> 'X' ORDER BY [LastName];
If you are doing a count, first remove the where section as its not doing anything helpful
Next calculate I, possibly using a DCount like this:
Code:I = DCount("Email","[" & dest & "]")
Finally put the value of I into your form
orCode:Me.nnum = I
Code:Forms!ResultFm.nnum=I
Or to do it in one step:
Code:Me.nnum=DCount("Email","[" & dest & "]")
How about this:
Code:Me.nnum=DCount("Email","[" & dest & "]","Language <> 'X'")
I tried yours. It does not work. But I have modified your proposal as below. It does not complain and runs. The problem is it gives I=0 whereas I know that there are at least 400 records in the table.OK I will try that but at the moment I am having another problem where "The button you clicked has not produced any event" or"...event refers to an external object". Where as I did not touch any other part of the application.
J = DCount("EMAIL", "[" & dest & "]", "[Language] = 'X'")
I am so sorry am using I as alias to J. In any case unfortunately it does not work.I = 0, because you are saving it in another
variable, J.
It works like charme.alias only applies to table and not to
variables.
this is a sample:
if you have a form (Form1), and the textbox
you want to update is Textbox1, set the Control
Source Property (Data) of Textbox1 to:
=DCount("Email", "[" & Dest & "]", "[Language]='X'")
on the Current Event of form Form1, you requery
the Textbox1:
Private Sub Form_Current()
On Error Resume Next
Me.Textbox1.Requery
End Sub
I =Nz(DCount("Email", "[" & Dest & "]", "[Language]='X'"),0)
try this ( NZ ---- )
for exampele
Code:I =Nz(DCount("Email", "[" & Dest & "]", "[Language]='X'"),0)