Results 1 to 2 of 2
  1. #1
    Shamli is offline Competent Performer
    Windows 7 64bit Access 2013 64bit
    Join Date
    Jul 2018
    Location
    California
    Posts
    142

    Form not to display the deleted records

    I have an employee, project and EmpToProj table.
    Many to many relationships.
    If a project is removed from the employee.
    The admin can do that.
    It is removed in the emptoproj table.

    Now my problems is:
    This is all for the timesheet.
    Everytime an employee opens the timesheet to enter his hours.
    The projects which he had already filled for the previous weeks displays. Without hours.
    So that the employee need not manually choose the projects everytime.

    If the project is removed from the employee.
    It should not show in the timesheet.
    Rest of the projects should show.
    How shall I proceed?

    I need a query to display only the current projects under the employee in the timesheet.


    Query which I used to remove the projects from the employee is:
    Private Sub cmdRemove_Click()
    On Error GoTo cmdRemove_Click_Error
    Dim sSQL As String
    Dim rSQL As String


    Dim nMid As Long 'Member
    Dim nWid As Long 'Event
    Dim varRow As Variant
    Dim ctlChosen As Control
    If Len(lstEmployee.Column(0) & vbNullString) = 0 Then
    MsgBox "There is no Member selected.", vbOKOnly + vbInformation, " I N P U T N E E D E D "
    Exit Sub
    End If
    nMid = lstEmployee.Column(1)
    'Check that at least one item has been selected
    If lstAssigned.ItemsSelected.Count = 0 Then
    MsgBox "Please select an event to remove from this Members's list.", vbOKOnly + vbInformation, _
    " I N P U T N E E D E D "
    lstAssigned.SetFocus
    Exit Sub
    End If
    Set ctlChosen = lstAssigned
    For Each varRow In ctlChosen.ItemsSelected
    nWid = ctlChosen.Column(0, varRow)
    sSQL = "DELETE * FROM EmpToProj WHERE EmployeeID = " & nMid & " AND ProjectID = " & nWid & ";"


    CurrentDb.Execute sSQL, dbFailOnError
    lstAvailable.Requery
    lstAssigned.Requery
    Next varRow

    cmdRemove_Click_EXIT:
    Set ctlChosen = Nothing
    Exit Sub
    cmdRemove_Click_Error:
    Select Case Err
    Case Else
    Call fcnLogError(Err.Number, Err.Description)
    End Select
    Resume cmdRemove_Click_EXIT
    End Sub

  2. #2
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,840
    Unfortunately, none of this shows how the timesheet query gets its records and what those fields are. Probably that query needs to be modified so as to include the EmpToProj table, or if it already does, the criteria needs to restrict records that are only in the many table. Not sure I agree with the notion of doing all this work when maybe all that's needed is to Update the assigned person in the many table. If you reassign the project, you have to write the whole record back with a different person instead of just updating the assignment. If no one is assigned right away, the update can simply be Null. If no one is ever assigned in the future, is this info of any future use, such as capturing all projects that were assigned and never got reassigned? Maybe that would be an indication of a business problem.

    P.S. you didn't use code tags as requested.
    There would be a couple of things I would change in your code. One being that a Select Case block isn't much use when there are no cases, plus at least one variable that's declared but isn't used (rSQL ). I probably wouldn't declare an object in lieu of simply referring to the form control.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

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

Similar Threads

  1. Replies: 4
    Last Post: 04-30-2018, 06:11 AM
  2. Records being deleted
    By RikkiHolland in forum Access
    Replies: 1
    Last Post: 03-07-2017, 02:47 PM
  3. Deleted records not actually deleted
    By soco3594 in forum Forms
    Replies: 6
    Last Post: 11-17-2015, 07:18 PM
  4. DELETE records are not deleted
    By victorqedu in forum Access
    Replies: 2
    Last Post: 10-26-2014, 10:23 AM
  5. ##deleted records##
    By FJM in forum Access
    Replies: 5
    Last Post: 10-23-2013, 08:08 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