Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2005
    Posts
    40

    Post Unanswered: Add a Record with a Select Case Function



    I finally have my select case working fine, but I can NOT figure out how to add a new employee record before setting the new values..... I keep writing over the original record..... .

    ANY Suggestions??

    Set DefaultTS = Screen.ActiveForm

    For Each WeekDay In DefaultTS.Controls
    'DoCmd.GoToRecord , , acNewRec

    'Only check data entry type controls.
    Select Case WeekDay.ControlType
    Case acSubform
    'EdittedSubForm = WeekDay & "N"

    ' Skip the active Sub Form.

    If WeekDay.Name <> sfrm And WeekDay.Name & "N" <> Eligible(0) _
    And WeekDay.Name <> sfrm And WeekDay.Name & "N" <> Eligible(1) _
    And WeekDay.Name <> sfrm And WeekDay.Name & "N" <> Eligible(2) _
    And WeekDay.Name <> sfrm And WeekDay.Name & "N" <> Eligible(3) _
    And WeekDay.Name <> sfrm And WeekDay.Name & "N" <> Eligible(4) _
    And WeekDay.Name <> sfrm And WeekDay.Name & "N" <> Eligible(5) _
    And WeekDay.Name <> sfrm And WeekDay.Name & "N" <> Eligible(6) Then
    DoCmd.RunCommand acCmdRecordsGoToNew

    'MsgBox WeekDay.Name

    'If MyControl.Name = "Employee" And MyControl.Value = EmployeeLink Then
    'MsgBox "Eelink '" & EmployeeLink & "' already exists"
    'End If

    For Each MyControl In WeekDay.Controls
    'MsgBox WeekDay.Name & Chr(13) & Chr(13) & MyControl.Name

    'AutoFill the Controls

    Select Case MyControl.Name

    Case "Employer": MyControl.Value = Employer
    Case "Employee Number": MyControl.Value = EmployeeNumber
    Case "X Code": MyControl.Value = XCode
    Case "Y Code": MyControl.Value = YCode
    Case "Z Code": MyControl.Value = ZCode
    Case "Employee": MyControl.Value = EmployeeLink
    Case "Start": MyControl.Value = EnteredStart
    Case "Finish": MyControl.Value = EnteredFinish
    Case "Break": MyControl.Value = EnteredBreak
    Case "Hours": MyControl.Value = EnteredHours
    Case "CreatedDate": MyControl.Value = Now()

    End Select

    Next MyControl

    End If
    Set MyControl = Nothing

    End Select
    DoCmd.RunCommand acCmdSaveRecord
    Next WeekDay
    Set WeekDay = Nothing

    TryNextWeekDay:
    Exit Function

  2. #2
    Join Date
    Feb 2004
    Location
    Chicago, IL
    Posts
    1,312
    If what you posted is accurate then it looks to me like the line that moves to a new record:

    'DoCmd.GoToRecord , , acNewRec

    Is commented out.

  3. #3
    Join Date
    Jan 2005
    Posts
    40
    I commented it out, because it doesn't work........ so I left it in case I found an answer to my question.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •