Results 1 to 3 of 3
  1. #1
    behnam is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2014
    Posts
    72

    How to use user input from textbox in function (ie. DCount)

    Hi all,



    For one of my queries i use the function Dcount in the form
    Code:
    Text16 = DCount("[Resolved?]", "Power Outages", "[Resolved?]=true AND [Date Added] like '*2014'")
    this basically counts all the records in the table Power Outages which has Resolved=true and the last 4 characters of the string date Added has to end in 2014. This works. Now im taking it a step further and allowing user input. i have a textbox called Text188 and the user enters the year. based on what they enter I would like to modify the code so instead of 2014 its the year they entered.

    I tried:
    Code:
    Text16 = DCount("[Resolved?]", "Power Outages", "[Resolved?]=true AND [Date Added] like '*Text188'")
    but the following does not work. Can anyone tell me how to do this.

    All the Best,
    Ben.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    The text box must resolve outside the quotes...

    Text16 = DCount("[Resolved?]", "Power Outages", "[Resolved?]=true AND [Date Added] like '*" & text188 & "'")

  3. #3
    behnam is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2014
    Posts
    72
    Thank You very much for your help.

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

Similar Threads

  1. Dcount using textbox with like
    By naeemahmad in forum Programming
    Replies: 7
    Last Post: 04-23-2014, 04:14 PM
  2. dcount function - new to Access VBA
    By jillp in forum Programming
    Replies: 7
    Last Post: 09-20-2012, 06:35 AM
  3. DCOUNT function with IN statement
    By dwilson in forum Access
    Replies: 2
    Last Post: 08-12-2011, 09:54 AM
  4. DCount function problem
    By 10 Gauge in forum Forms
    Replies: 5
    Last Post: 02-28-2011, 02:08 PM
  5. Replies: 0
    Last Post: 06-11-2009, 09:51 AM

Tags for this Thread

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