Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 263
  • Last Modified:

Ability To Control DefaultDates

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
    Else
        If Me.lstCustomers.ItemsSelected.Count > 0 Then

            rs.MoveFirst
            Do Until rs.EOF
                CurrentDb.Execute _
                    "Insert Into tblOrders(CustomerID, OrderDate) " & _
                    "Values (" & Me.lstCustomers.Column(0) & ",  #" & rs(0) & "#)", dbFailOnError
                                                                '#" & Me.MonthView.Value & "#
                   
                rs.MoveNext
            Loop
            Else
            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 & "#)"
           
            Me.lstOrderDates.Requery
End Sub
0
DanaCurnock
Asked:
DanaCurnock
1 Solution
 
Rey Obrero (Capricorn1)Commented:
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")
           
            Me.lstOrderDates.Requery
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")

to

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


0
 
DanaCurnockAuthor Commented:
Capricorn1:

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

Dana
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now