Results 1 to 15 of 15
  1. #1
    gbmarlysis is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Dec 2011
    Posts
    48

    dcount wildcards


    if i have a field filled like this.....lathl15/06/11 how can i use a dcount to calculate how many records are before a certain date shown in a text box.
    thanks

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,972
    what is the 'lathl' part - does this change in characters and length?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    gbmarlysis is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Dec 2011
    Posts
    48
    its a description of who hosted the race meet, always 4 letters but characters change

  4. #4
    gbmarlysis is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Dec 2011
    Posts
    48
    was upposed to show r1 at the end to indicate race number

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,972
    I see 5 characters before the date. Will have to extract the date part. Assuming the date structure can be relied on (dd/mm/yy with placeholder zeros).

    Unfortunately, CDate(Mid("lathl15/06/11",6)) reads the 15 as year so this gets a little complicated.

    x = "lathl15/06/11"
    CDate(Mid(x,9,2) & "/" & Mid(x,6,2) & "/" & Right(x,2))

    Now apply date value as filter criteria on this constructed field.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    gbmarlysis is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Dec 2011
    Posts
    48
    is it easier to extract the date in a table.
    make it its own field in Race results table

  7. #7
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,972
    Didn't see your other post.

    CDate(Mid(x,9,2) & "/" & Mid(x,6,2) & "/" & Mid(x,12,2))

    You mean a calculated field in table? Maybe, haven't used that new Access 2010 datatype yet. Try it.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  8. #8
    gbmarlysis is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Dec 2011
    Posts
    48
    that code you typed june where would it go in a dcount expression, and if you could explain it a bit that would help me understand the layout for future expressions
    TY

  9. #9
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,972
    I am suggesting you use that to create a field in a query, like:

    RaceDate: CDate(Mid(x,9,2) & "/" & Mid(x,6,2) & "/" & Mid(x,12,2))

    Use field name in place of x.

    Then use the query in place of table in the DCount

    =DCount("[Athlete ID]", "[query name here]", "[Athlete Id]='" & Me.Combo35 & "' AND RaceDate<#" & Forms!mainformname.datetextboxname & "#")

    If you use report Grouping & Sorting with aggregate calcs functionality to manipulate and organize data, the DCount might not be required.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  10. #10
    gbmarlysis is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Dec 2011
    Posts
    48
    what does the code Mid(x,6,2) mean
    ty

  11. #11
    gbmarlysis is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Dec 2011
    Posts
    48
    hi i typed this '=CDate(Mid("[Race Id]",9,2) & "/" & Mid("[Race Id]",6,2) & "/" & Mid("[Race Id]",12,2))' into the criteria of a new field in a query
    raceid as the field
    says data type mismatch in criteria expression

  12. #12
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,972
    Not what I suggested. I said create a field in query with that expression.

    RaceDate: CDate(Mid("[Race Id]",9,2) & "/" & Mid("[Race Id]",6,2) & "/" & Mid("[Race Id]",12,2))

    Then use reference to the form textbox as criteria under this constructed field.

    You really should keep these data in separate fields.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  13. #13
    gbmarlysis is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Dec 2011
    Posts
    48
    sorry no idea what all that means thanx for your help anyway. i created a new field in the query not sure where to put the expression. going to go try a dif approach.

  14. #14
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,972
    Query in design view.

    The expression goes on the Field row of query.

    Reference to textbox goes on Criteria row of query under that field.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  15. #15
    gbmarlysis is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Dec 2011
    Posts
    48
    that makes it so much clearer... thanks June. i took your advice on creating a new date field and used the above AND function with the date and it works great. if theres no value in the date text box the dcount textbox says error but i can live with that, as soon as i put in a date it works.

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

Similar Threads

  1. WildCards in VB Code
    By Juan4412 in forum Programming
    Replies: 5
    Last Post: 06-25-2011, 10:50 PM
  2. VBA Wildcards
    By dssrun in forum Programming
    Replies: 11
    Last Post: 03-31-2011, 08:44 AM
  3. SQL Wildcards
    By sandlucky in forum Queries
    Replies: 4
    Last Post: 03-28-2011, 03:31 AM
  4. Using wildcards (*) in SQL
    By SIGMA248 in forum Queries
    Replies: 1
    Last Post: 07-22-2010, 08:44 PM
  5. Wildcards?!
    By esx_raptor in forum Access
    Replies: 3
    Last Post: 02-19-2010, 03:22 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