syntax error

L

lilbit27

How can I tie the users shortname to this code. so it comes back with
the results that only apply to them.

Dim pastdue As Integer
Dim current As Integer
Dim tot As Integer

nodate = DCount("*", "TARA", "isNull(penddte)")
pastdue = DCount("*", "TARA", "penddte < date()")
current = DCount("*", "TARA", "penddte >= date()")
tot = DCount("*", "TARA")

Debug.Print nodate, pastdue, current, tot
Me.message = "You have " & tot & " items with " & pastdue & " past
due, " & current & " current and " & nodate & " with no pending date"


End Sub


Right now it totals the entire database. I have a text box called
txtusername that captures the users shortname when they login (using a
function) that same shortname is in the maintable and that field is
called Login id.

So what I would want to say is: count the number of items where the
"penddte"(another field in the maintable) isnull and the txtusername
is = to the field called loginid. I don't think I have my syntax
correct. i get an cancell operation error.
nodate = DCount("*", "TARA", "isNull(penddte)" & " and [loginID]= " &
Me.txtUserName)
 
C

Carl Rapson

if txtUserName is a string, try putting quotes around the value in the
DCount call:

nodate = DCount("*", "TARA", "isNull(penddte)" & " and [loginID]= '" &
Me.txtUserName & "'")

Carl Rapson
 
G

Guest

Something like:
nodate = DCount("*", "TARA", "isNull(penddte) AND [Login id]='" & Me!txtusername & "'")
pastdue = DCount("*", "TARA", "penddte < date() AND [Login id]='" & Me!txtusername & "'")
current = DCount("*", "TARA", "penddte >= date() AND [Login id]='" & Me!txtusername & "'")
tot = DCount("*", "TARA","[Login id]='" & Me!txtusername & "'" )

-Dorian

lilbit27 said:
How can I tie the users shortname to this code. so it comes back with
the results that only apply to them.

Dim pastdue As Integer
Dim current As Integer
Dim tot As Integer

nodate = DCount("*", "TARA", "isNull(penddte)")
pastdue = DCount("*", "TARA", "penddte < date()")
current = DCount("*", "TARA", "penddte >= date()")
tot = DCount("*", "TARA")

Debug.Print nodate, pastdue, current, tot
Me.message = "You have " & tot & " items with " & pastdue & " past
due, " & current & " current and " & nodate & " with no pending date"


End Sub


Right now it totals the entire database. I have a text box called
txtusername that captures the users shortname when they login (using a
function) that same shortname is in the maintable and that field is
called Login id.

So what I would want to say is: count the number of items where the
"penddte"(another field in the maintable) isnull and the txtusername
is = to the field called loginid. I don't think I have my syntax
correct. i get an cancell operation error.
nodate = DCount("*", "TARA", "isNull(penddte)" & " and [loginID]= " &
Me.txtUserName)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top