Ability To Control DefaultDates

Posted on 2005-04-27
Last Modified: 2008-02-01
I need to have the ability to temporarily remove Default Dates in the following code:

Private Sub cmdDefaults_Click()
Dim rs As Recordset
Set rs = CurrentDb.OpenRecordset("Select OrderDate from tblDefaultDates")
If rs.EOF Then
    MsgBox "No Dates."
    Exit Sub
        If Me.lstCustomers.ItemsSelected.Count > 0 Then

            Do Until rs.EOF
                CurrentDb.Execute _
                    "Insert Into tblOrders(CustomerID, OrderDate) " & _
                    "Values (" & Me.lstCustomers.Column(0) & ",  #" & rs(0) & "#)", dbFailOnError
                                                                '#" & Me.MonthView.Value & "#
            MsgBox "Please Select A Customer."
            Exit Sub
        End If
End If
End Sub

The fields that are in the tblDefaultDates are:
ID      CustomerID      OrderDate      Transferred
1      1823                          3/9/2005 No

I want to be able to open the tblDefaultDates and click on those dates that should not be "transferred". (Transferred = False) After clicking the Sub cmdDefaults_Click event, I want the all values in the tblDefaultDates.Transferred = True.

To initially make the tblDefaultDates.Transferred = True, I would need to change this code too.

Private Sub MonthView_DateClick(ByVal DateClicked As Date)
    CurrentDb.Execute _
            "Insert Into tblDefaultDates(OrderDate) " & _
            "Values(#" & Me.MonthView.Value & "#)"
End Sub
Question by:DanaCurnock
    LVL 119

    Accepted Solution

    first use this

    Private Sub MonthView_DateClick(ByVal DateClicked As Date)

        CurrentDb.Execute _
                "Insert Into tblDefaultOrders(OrderDate) " & _
                "Values(#" & Me.MonthView.Value & "#)"
        CurrentDb.Execute _
                "update tbldefaultorders set transferred=-1 " & _
                "where id=" & DMax("id", "tbldefaultorders")
    End Sub

    at this point all the dates entered to tbldefaultorders will have a status Transferred =true.

    then you will unchecked all the dates that you don't want to use for a particular client, right?

     from the codes above  cmdDefault_click

    change this line

    Set rs = CurrentDb.OpenRecordset("Select OrderDate from tblDefaultDates")


    Set rs = CurrentDb.OpenRecordset("Select OrderDate from tblDefaultDates where transferred=-1")


    Author Comment


    Thanks. I finally have the ability to do what I needed a few months ago...


    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Join & Write a Comment

    QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
    In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
    Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now