Page 1 of 2 12 LastLast
Results 1 to 15 of 28
  1. #1
    azhar2006's Avatar
    azhar2006 is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2012
    Posts
    526

    Stop the introduction of records

    Hello guys
    I used this expression, a good


    = DCount ("*"; "tbStudents"; "(field = '1')")
    But I want to add anything
    Is when the number 75 is to stand for the introduction of records bearing the number (1)

    Also, the results are incorrect
    Click image for larger version. 

Name:	12.JPG 
Views:	18 
Size:	29.8 KB 
ID:	15369Click image for larger version. 

Name:	22.JPG 
Views:	18 
Size:	28.6 KB 
ID:	15370

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,863
    Your expression is returning a value. You can evaluate that value using VBA. You could also manage the entire thing in VBA.


    You could start by placing the following in a click event to evaluate the code.
    Code:
    Dim intCount as integer
    
    intCount  = DCount ("*"; "tbStudents"; "(field = '1')")
    
    msgbox intCount
    Eventually, after you fine tune your DCount, you can do something with your variable, "intCount"

  3. #3
    azhar2006's Avatar
    azhar2006 is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2012
    Posts
    526
    Thank you ItsMe
    Regarding
    But I want to add anything
    Is when the number 75 is to stand for the introduction of records bearing the number (1)

    Click image for larger version. 

Name:	1444.JPG 
Views:	18 
Size:	15.0 KB 
ID:	15371

  4. #4
    MarvinM's Avatar
    MarvinM is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Dec 2013
    Posts
    30

    Cool

    Azhar,

    Take out the single quotes and parens in your criteria.
    Code:
    = DCount ("*"; "tbStudents"; "field = 1")
    = DCount ("*"; "tbStudents"; "field = 2")
    = DCount ("*"; "tbStudents"; "field = 3")
    = DCount ("*"; "tbStudents"; "field = 4")
    Good Luck!

  5. #5
    MarvinM's Avatar
    MarvinM is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Dec 2013
    Posts
    30
    Azhar,
    Quote Originally Posted by azhar2006 View Post
    But I want to add anything
    Is when the number 75 is to stand for the introduction of records bearing the number (1)
    Can you try another translator? The statements about "add anything" and "the number 75" just don't make sense in English. I can't figure out what you need.

  6. #6
    Xipooo's Avatar
    Xipooo is offline Sr. Database Developer
    Windows 8 Access 2013
    Join Date
    Jan 2014
    Location
    Arizona
    Posts
    332
    Personally, I don't like any D function which uses * as the returning field. Although I don't have hard evidence to support it, I'm pretty sure this is returning more data than is necessary to perform the calculation. Specify only a single field to return in your D functions. They should run faster and chew up less memory.

    Other than that, I don't understand your question. May I suggest http://www.bing.com/translator

  7. #7
    azhar2006's Avatar
    azhar2006 is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2012
    Posts
    526
    Well
    Among students
    In the classroom students

    Each row accommodated a number of students. For example, 20 students
    Rows in the school room 4
    Must be in each row 20 students and stop sending additional student

  8. #8
    azhar2006's Avatar
    azhar2006 is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2012
    Posts
    526
    Forgot
    Thank you Xipooo
    Website translation

  9. #9
    MarvinM's Avatar
    MarvinM is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Dec 2013
    Posts
    30
    Xipooo is right. If the name of your field in tbStudents really is "field", don't use reserved words.
    But if that is the case, try this:
    Code:
    = DCount ("[field]"; "tbStudents"; "[field] = 1")
    Then, of course, change the name of [field] to something other than a reserved word, like NbrOfStudents.

    Hey, is this a homework assignment?

  10. #10
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,863
    Quote Originally Posted by azhar2006 View Post
    Is when the number 75 is to stand for the introduction of records bearing the number (1)
    You will need to implement additional code to analyze the variable, "intCount". The message box will help you to correctly construct your DCount statement.

    After you get your Dcount functioning correctly, create some code to analyze the value of your variable.

    If inCount = 75 then
    msgbox "No More Students Please!"
    <More Code to cancel user's request>
    End If

  11. #11
    ipisors is offline Access Developer
    Windows XP Access 2007
    Join Date
    Sep 2013
    Posts
    119
    What in the world are semicolons doing in your Dcount() ??

    Replace them with commas

  12. #12
    azhar2006's Avatar
    azhar2006 is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2012
    Posts
    526
    Thank you all for support
    That (field) source of the query and not the table
    Click image for larger version. 

Name:	AS.JPG 
Views:	9 
Size:	44.9 KB 
ID:	15381

  13. #13
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,863
    Field is a reserved word. It is recommended to not use reserved words in names or alias'. If you are using "Field" as an alias, make sure you enclose the name in brackets. [Field]

    Do you still have a question about how to accomplish your task?

  14. #14
    azhar2006's Avatar
    azhar2006 is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2012
    Posts
    526
    Thank you Its
    Yes, I'm still stuck

  15. #15
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,863
    Are you able to get the count of records where Field = 1 and store that value in the variable intCount ?

    Do you get a message box with the correct count?

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Good introduction to programming in Visual Basic?
    By sshepard in forum Programming
    Replies: 1
    Last Post: 09-22-2011, 11:07 AM
  2. Replies: 1
    Last Post: 05-10-2011, 12:06 PM
  3. Introduction and Questions
    By sblanky in forum Access
    Replies: 2
    Last Post: 01-19-2011, 08:12 PM
  4. stop access from auto adding records
    By svcghost in forum Forms
    Replies: 2
    Last Post: 10-21-2010, 05:25 PM
  5. Replies: 2
    Last Post: 11-29-2009, 12:00 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums - Senior Forums