Results 1 to 7 of 7
  1. #1
    MintChipMadness is offline Competent Performer
    Windows XP Access 2010 32bit
    Join Date
    Jun 2012
    Posts
    109

    Expression Help - Pulling a number from a text box.

    I am trying to pull a number from a text box. I listed the expression for the box below. [Current Record] is a number and Count(*) is a number. I couldn't figure out what field gave me the total records so I did a count instead. If I want to pull the value from just the count portion, what expression would do that? Please no VBA. Thank you.



    Code:
    =[CurrentRecord] & " of " & Count(*)
    please note the spaces on either side of "of"

  2. #2
    John_G is offline VIP
    Windows XP Access 2003
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    What do you want to do with the value resulting from count(*) ? Using it by itself as the source for a textbox works fine, so all you need to do is reference that textbox.

    Are you using this in a form or a report?

    John
    Last edited by John_G; 08-08-2012 at 01:00 PM. Reason: Additional question

  3. #3
    MintChipMadness is offline Competent Performer
    Windows XP Access 2010 32bit
    Join Date
    Jun 2012
    Posts
    109
    I can't use a count function in my if statement of a button I created. I created a next record button on a form and when the button reaches the same amount of records as the total records it doesn't go any further. For some reason the macro errors and says I can't use the count function in the statement. I created the text box from my first post on the same form and the work around would be to pull the total from that text box.

  4. #4
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    What exactly are you trying to count?
    If the number of records in a table or query, then I would use the DCOUNT function. If you leave off the criteria argument, it will return the total record count for that object.
    See: http://office.microsoft.com/en-us/ac...001228817.aspx

  5. #5
    John_G is offline VIP
    Windows XP Access 2003
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    I'm not sure if the Count(*) will work as you want it to in this situation anyway. It gives you the proper number of records when you first open the form, but as you add more, it is not updated.

    All this information is readily available in the record navigation bar at the bottom of the form - is there a reason why you need it on the form, too?

    The reason for the error is probably because if you explicitly (code or macro) try to move to the next record when you are already on the last one, it will give you an error.

    John

  6. #6
    MintChipMadness is offline Competent Performer
    Windows XP Access 2010 32bit
    Join Date
    Jun 2012
    Posts
    109
    Dcount worked. I am trying to create the form for people that haven't used access before. Some people won't know to look at the tiny record navigation bar at the bottom.

    Out of curiosity, how would I extract the information for the string? I figured out the position of the first space using InStr and added 3 to get to the position of the last space. I then got stuck on finding a function that prints everything after that point. Is there a function that does that?

  7. #7
    MintChipMadness is offline Competent Performer
    Windows XP Access 2010 32bit
    Join Date
    Jun 2012
    Posts
    109
    got it!!

    =Mid([recordtotals],(InStr([recordtotals]," ")+4))

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 08-03-2012, 01:22 PM
  2. Replies: 2
    Last Post: 07-21-2012, 01:21 AM
  3. Replies: 2
    Last Post: 04-13-2011, 09:42 AM
  4. Replies: 1
    Last Post: 10-24-2010, 07:42 PM
  5. pulling text values into FK number column
    By REBBROWN in forum Database Design
    Replies: 2
    Last Post: 08-30-2010, 05:04 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