Results 1 to 4 of 4
  1. #1
    alsoto is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Apr 2009
    Posts
    67

    Default Min & Max Date Values in Form

    Hello,



    I have a parameter form for a report. In it, I have a field for a start date (StartD) and an end date (EndD). I would like the fields' default values to be the earliest and latest date (StartDate) in my table (tblStudents).

    I found this code in an Access 2000 book, but it isn't doing anything when I open the form:

    Private Sub Form_Load()
    Dim DateRange As New Recordset
    DateRange.Open _
    "SELECT Min(DateValue(StartDate)) as SDate," & _
    "Max(DateValue(StartDate)) as EDate " & _
    "FROM tblStudents", _
    CurrentProject.Connection
    Me.StartD = DateRange!Sdate
    Me.EndD = DateRange!Edate
    End Sub

    Can anybody tell me why it doesn't work?

    Thanks,
    Al

  2. #2
    RayMilhon is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Aug 2011
    Location
    Southern California
    Posts
    1,067
    Are me.StartD and Me.EndD Textboxes on your form? Also are they unbound?

  3. #3
    alsoto is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Apr 2009
    Posts
    67
    Yes and Yes.
    Last edited by alsoto; 10-03-2011 at 10:49 AM. Reason: Yes, unbound text boxes on my form.

  4. #4
    RayMilhon is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Aug 2011
    Location
    Southern California
    Posts
    1,067
    Next thing I would do is put a breakpoint on the Daterange.open and use f8 to step through the code and see what it's doing in each step.
    After each press of the f8 key in the immediate window type in ?me.StartD see what's there. then type in ?me.EndD and again see what's there.

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

Similar Threads

  1. Default Values in a form
    By handjor in forum Forms
    Replies: 3
    Last Post: 08-03-2011, 09:11 AM
  2. Multiple default values in listbox
    By rickscr in forum Forms
    Replies: 3
    Last Post: 04-07-2011, 09:49 AM
  3. option group default values
    By wlumpkin in forum Access
    Replies: 3
    Last Post: 02-15-2011, 03:30 PM
  4. date range form values as parameters
    By cfnieder in forum Forms
    Replies: 8
    Last Post: 08-11-2010, 01:48 PM
  5. Default Values
    By twainscott in forum Programming
    Replies: 0
    Last Post: 09-14-2006, 11:18 AM

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