Results 1 to 3 of 3
  1. #1
    Ekhart is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jun 2016
    Posts
    80

    VBA to enter date to field

    I have a VBA script which autofilters data on a datasheet form. What I would like is for the VBA to use the same criteria it is filtering by to enter a bit of text in to the first field on the form (Alert). An example of the autofilter is:


    Code:
    "[DateofConsult]<" & Format(myval, "\#m/d/yyyy\#")
    . This code basically filters any consult that is older than 120 days old. I would like for it to put in the Alert column 'Older than 120 days' so the person running this will know why it hit there. There are many different filters so I want to make it as clear as possible.

    I have done this with queries before but due to uncontrollable limitations on my office network, the large union query runs incredibly slow compared to filtering and with union queries I was unable to have an editable query/datasheet form.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    in the query you use behind the form, add an extra field for days: Days: DateDiff("d",[DateofConsult],Date)
    then under it as criteria, put >120

    save as a filter or use vb to filter the days.

  3. #3
    Ekhart is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jun 2016
    Posts
    80
    This is a good start but since there are many different criteria (not just a date) I am looking at it wont work overall. I really just want a way to use my string and have it use the same info it is using to filter, to add text to the empty 'Alert' field. I can do this with conditional formatting but I would much prefer clear text to a special color to mean something specific has to be done.

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

Similar Threads

  1. Replies: 1
    Last Post: 12-28-2016, 11:39 AM
  2. Date enter query please help
    By TheSpecialist in forum Queries
    Replies: 1
    Last Post: 05-27-2016, 08:18 AM
  3. Field auto enter new line on enter event
    By Ruegen in forum Forms
    Replies: 3
    Last Post: 09-17-2013, 09:00 PM
  4. Enter current date and time into subform field
    By tonybrecko in forum Forms
    Replies: 8
    Last Post: 06-16-2013, 09:58 PM
  5. Replies: 5
    Last Post: 02-06-2011, 04:32 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