By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,836 Members | 2,011 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,836 IT Pros & Developers. It's quick & easy.

Truble with a Dcount

MGrowneyARSI
P: 90
Hello I'm having some truble with some dcounts that I am useing to see if I want to show 2 buttons or not the dcountss are looking at two querrys that are limited to records were a bolean field is set to false they are counting the P.K. where the User_Name is equal to the login name the user-name is a lookup of the login name and there are record in the query where the login name and the user_name are the same It must be some sort of syntax issue here is the code TIA
Expand|Select|Wrap|Line Numbers
  1.     If DCount("[Self_App_ID]", "Show_Self", "[User_Name]" = [Forms]![Login]![AskName]) > 0 Then
  2.         Me.Open_Self.Visible = True
  3.     Else
  4.         Me.Open_Self.Visible = False
  5.     End If
  6.     MsgBox Forms!Login!AskName
  7.     MsgBox DCount("[App_ID]", "Show_ThreeSixty", "[User_Name]" = [Forms]![Login]![AskName])
  8.     If DCount("[App_ID]", "Show_ThreeSixty", "[User_Name]" = [Forms]![Login]![AskName]) > 0 Then
  9.         Me.Open_ThreeSixty.Visible = True
  10.     Else
  11.         Me.Open_ThreeSixty.Visible = False
  12.     End If
Aug 28 '07 #1
Share this Question
Share on Google+
5 Replies


JKing
Expert 100+
P: 1,206
Without clearly specifying what error you are receiving I can only guess. My thoughts are that you've entered the criteria parameter string incorrectly. The = needs to be inside the quotes and I'm assuming your values are text data types and they must be enclosed by single quotes. Give this a shot.

Expand|Select|Wrap|Line Numbers
  1.     If DCount("[Self_App_ID]", "Show_Self", "[User_Name] = '" & [Forms]![Login]![AskName] & "'") > 0 Then
  2.         Me.Open_Self.Visible = True
  3.     Else
  4.         Me.Open_Self.Visible = False
  5.     End If
  6.     MsgBox Forms!Login!AskName
  7.     MsgBox DCount("[App_ID]", "Show_ThreeSixty", "[User_Name] = '" & [Forms]![Login]![AskName] & "'")
  8.     If DCount("[App_ID]", "Show_ThreeSixty", "[User_Name] =  '" & [Forms]![Login]![AskName] & "'") > 0 Then
  9.         Me.Open_ThreeSixty.Visible = True
  10.     Else
  11.         Me.Open_ThreeSixty.Visible = False
  12.     End If
Aug 28 '07 #2

MGrowneyARSI
P: 90
The issue was that my dcounts were returning a 0 value but that code worked great I allways though the "'" duble quotes were used when dealing with numbers you wouldn't know a good site that explian all of the diferent Dlokup syntax and uses would you because I use them alot in my code but don't fully understand them
Aug 28 '07 #3

JKing
Expert 100+
P: 1,206
After the changes are they still returning zero or does it work properly now?
Aug 28 '07 #4

JKing
Expert 100+
P: 1,206
Also take a look at this link to the Articles section. It explains the quotes.
Where, when and which quotes to use
Aug 28 '07 #5

MGrowneyARSI
P: 90
No the DCounts are working fine now thank you very much I'll take a look at that artical
Aug 28 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.