Results 1 to 6 of 6
  1. #1
    wjburke2 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2014
    Posts
    3

    Angry Cant alter a combo box value list

    My user asked me to make a small change to form in MS Access. He wanted me to add a additional option to a drop down. No problem I thought the value is derived from a Combo Box value list which has three values "Up","Down";"Idle". When I first brought up the list it only showed "Up";"Down" in the value list field but Up, Down and Idle showed in Form View Combo Box. I played around opening the form in layout view, now Idle shows in the value list. So I added PM which was the original change request ("Up";"Down";"Idle";"PM"). No matter what I do the newly added PM does not show up. I checked, list rows is set to 8. I closed the form and reopened it, PM is in the value list but still not in the dropdown in Form view. Has anyone experienced this behavior in Access forms? This was supposed to be a quick fix that turned into a week long nightmare. I would appreciate any help I can get on this.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    the combo box is based on a table.
    did you add the new values to the table?
    IF you add values while the forms is open then the combo MUST be refreshed to get the new values. This can be done by clicking REFRESH ALL button on the menu.
    or add the code to a dbl-click on the form.... cboBox.requery

  3. #3
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2013 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Is there VBA code behind the form that sets the values for that list? Maybe in OnOpen or OnLoad.

  4. #4
    wjburke2 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2014
    Posts
    3
    Thanks for your help on this it has me scratching my head. I think I have checked the code but here is the code behind the form and the properties sheet. The control name is cmbStatus. I tried to up load some images of the screen but can't seen to get them loaded. When I select insert images then select From computer there is no "OK" or upload button. Maybe because I used quick reply or perhaps the site dosnt allow new posters to post images. Anyway here is the code and as I stated above the value list has Up, Down, Idle and PM but the control only shows Up, Down, and Idle.


    Code:
    Option Compare Database
    Dim strPurpose As String
    Private Sub Form_Load()
        Dim UserLevel As String
        sUser = Environ("username")
        
        UserLevel = DLookup("UserLevel", "Operators", "UserId = '" & sUser & "'")
        If UserLevel = 2 Then
            Me.btnAdd.Visible = True
            Me.btnDelete.Visible = True
        Else
            Me.btnAdd.Visible = False
            Me.btnDelete.Visible = False
        End If
        
        If Len(Nz(Me.OpenArgs, "")) > 0 Then
            ' This is a add or update from
            SplitArgs = Split(Me.OpenArgs, ";")
            If SplitArgs(0) <> "Edit" Then
                strPurpose = "AddNew"
                Add_New_Setup (SplitArgs)
            Else
                strPurpose = "Edit"
                Me.cmbStatus.Enabled = True
                Me.cmbStatus.Locked = False
                Me.txtMeter.Enabled = True
                Me.txtMeter.Locked = False
            End If
        Else
            strPurpose = "Update"
            Update_Setup
        End If
        
            
        If Me.Status_Key > "" Then
            txtFilter = "Status_Key = " & Me.txtStatus_Key
            Me.txtErrorDesc = DLookup("Problem", "Laser_Status_Info", txtFilter)
        End If
        
        Me.txtErrorDesc.Enabled = False
        Me.txtErrorDesc.Locked = True
        
        If IsNull(Me.cmbPrinter) Then
           Me.cmbPrinter = Me.cmbPrinter.ItemData(0)
        End If
        
        If Me.NewRecord Then
            Hide_Navigation
        Else
            Show_Navigation
        End If
        
    End Sub
    Private Sub Add_New_Setup(SplitArgs)
        Me.txtStatus_Key = SplitArgs(0)
        Me.cmbPrinter = SplitArgs(1)
        Me.txtShift_Key = SplitArgs(2)
        Me.Log_Key = GetNextNumber("Laser_Maint_Log", "Log_Key", 1)
        Me.cmbOperator = DLookup("Operator", "Shift_Log", "Shift_Key = " & Me.txtShift_Key)
        Me.txtLog_Date = DLookup("Err_Time", "Laser_Status_Info", "Status_Key = " & Me.txtStatus_Key)
        Me.cmbOperator.Enabled = False
        Me.cmbOperator.Locked = True
        Me.txtLog_Date.Enabled = False
        Me.txtLog_Date.Locked = True
        Me.cmbPrinter.Enabled = False
        Me.cmbPrinter.Locked = True
        Me.txtMeter.Enabled = True
        Me.txtMeter.Locked = False
        Me.cmbStatus.Enabled = True
        Me.cmbStatus.Locked = False
        Hide_Navigation
    '    btnAdd.Visible = False
    End Sub
    Private Sub Form_Close()
        If CurrentProject.AllForms("Error_List").IsLoaded Then
            DoCmd.Close acForm, "Error_List"
        End If
        
    End Sub
    Private Sub Update_Setup()
        If Me.txtShift_Key > "" Then
            Me.cmbOperator.Enabled = False
            Me.cmbOperator.Locked = True
            Me.cmbPrinter.Locked = True
            Me.cmbPrinter.Enabled = False
            Me.txtLog_Date.Enabled = False
            Me.txtLog_Date.Locked = True
            Me.txtMeter.Enabled = False
            Me.txtMeter.Locked = True
        
        Else
            Me.cmbOperator.Enabled = True
            Me.cmbOperator.Locked = False
            Me.cmbPrinter.Enabled = True
            Me.cmbPrinter.Locked = False
            Me.txtLog_Date.Enabled = True
            Me.txtLog_Date.Locked = False
            Me.txtMeter.Enabled = True
            Me.txtMeter.Locked = False
            Me.cmbStatus.Enabled = True
            Me.cmbStatus.Locked = False
            Me.cmbOperator.SetFocus
            
        End If
        
        Show_Navigation
    '    btnAdd.Visible = True
    End Sub
    Private Sub Form_Current()
    ''   Check for Add or Update Mode
    '    If Me.NewRecord Then
    '        Me.btnDelete.Visible = False
    '    Else
    '        Me.btnDelete.Visible = True
    '    End If
        
        If Not IsNull(cmbPrinter) Then
            Me.txtSvcPhone = DLookup("Phone", "Printer", "PrinterId = '" & [cmbPrinter] & "'")
            Me.txtSerialNum = DLookup("SerialNumber", "Printer", "PrinterId = '" & [cmbPrinter] & "'")
        End If
        
        If Not IsNull(Me.txtStatus_Key) Then
            txtFilter = "Status_Key = " & Me.txtStatus_Key
            Me.txtErrorDesc = DLookup("Problem", "Laser_Status_Info", txtFilter)
        Else
            Me.txtErrorDesc = ""
        End If
        Call Fill_Date_Time_Fields
        Call Compute_Times
        
        If Me.NewRecord Then GoTo Exit_Form_Current
            
        intCount = Me.Recordset.RecordCount
        intIndex = Me.Recordset.AbsolutePosition + 1
        
        If intCount = 1 Then
            Me.cmdFirst.Enabled = False
            Me.cmdPrevious.Enabled = False
            Me.cmdNext.Enabled = False
            Me.cmdLast.Enabled = False
            
        ElseIf intCount = intIndex Then
            Me.cmdPrevious.Enabled = True
            Me.cmdFirst.Enabled = True
            'Me.cmdPrevious.SetFocus
            Me.cmdNext.Enabled = False
            Me.cmdLast.Enabled = False
         
        ElseIf intIndex = 1 Then
            Me.cmdLast.Enabled = True
            Me.cmdNext.Enabled = True
            'Me.cmdNext.SetFocus
            Me.cmdFirst.Enabled = False
            Me.cmdPrevious.Enabled = False
            
        ElseIf intIndex > 1 And intIndex < intCount Then
            Me.cmdFirst.Enabled = True
            Me.cmdPrevious.Enabled = True
            Me.cmdNext.Enabled = True
            Me.cmdLast.Enabled = True
            
        End If
        
        Me.txtItemCount = intIndex & " of " & intCount
    Exit_Form_Current:
        
    End Sub
    Private Sub Form_BeforeUpdate(Cancel As Integer)
        Dim CancelUpd As Boolean
        
        CancelUpd = False
        
    '    If Not Validate_Data Then
    '       Cancel = True
    '       GoTo Exit_Form_BeforeUpdate
    '    End If
        
        If Not CancelUpd Then
          ' passed the validation process
            If Me.NewRecord Then
                If MsgBox("Data will be saved, Are you Sure?", vbYesNo, "Confirm") = vbNo Then
                    CancelUpd = True
                Else
                    ' run code for new record before saving
                End If
            Else
                If MsgBox("Data will be modified, Are you Sure?", vbYesNo, "Confirm") = vbNo Then
                    CancelUpd = True
                Else
                   ' run code before an existing record is saved
                End If
            End If
        
        End If
        
        ' if the save has been canceled or did not pass the validation , then ask to Undo changes
        If CancelUpd Then
                Me.Undo
        End If
    Exit_Form_BeforeUpdate:
        
    End Sub
    Private Sub cmbPrinter_AfterUpdate()
        Me.txtSvcPhone = DLookup("Phone", "Printer", "PrinterId = '" & [cmbPrinter] & "'")
        Me.txtSerialNum = DLookup("SerialNumber", "Printer", "PrinterId = '" & [cmbPrinter] & "'")
        
    End Sub
    ' **********************************
    '  Update Called Date Time
    ' **********************************
    Private Sub Called_GotFocus()
        If IsNull(Me.Called) Then
    '        Me.Called = Me.Log_Date
        End If
        Call Fill_Date_Time_Fields
        
    End Sub
    Private Sub txtCalledDt_AfterUpdate()
        
        If txtCalledTm = "" Then
            Me.txtCalledTm.SetFocus
            GoTo Exit_txtCalledDt_AfterUpdate
        
        ElseIf IsDate(txtCalledDt) Then
            txtCalled = txtCalledDt + CDate(txtCalledTm)
            If txtCalled > Now Then
                MsgBox "Called can not be furture date", vbInformation
                Me.txtCalledDt.SetFocus
                GoTo Exit_txtCalledDt_AfterUpdate
            End If
        
        End If
        Call Compute_Times
        Call Fill_Date_Time_Fields
    Exit_txtCalledDt_AfterUpdate:
    End Sub
    Private Sub txtCalledTm_AfterUpdate()
            
        If Not IsDate(txtCalledDt) Then
            MsgBox "Please enter a valid date", vbInformation
            Me.txtCalledDt.SetFocus
            GoTo Exit_txtCalledTm_AfterUpdate
        
        ElseIf IsDate(txtCalledTm) Then
            txtCalled = txtCalledDt + txtCalledTm
            If txtCalled > Now Then
                MsgBox "Called can not be furture date", vbInformation
                Me.txtCalledDt.SetFocus
                GoTo Exit_txtCalledTm_AfterUpdate
                
            End If
        End If
        
        Call Compute_Times
        Call Fill_Date_Time_Fields
    Exit_txtCalledTm_AfterUpdate:
    End Sub
    Private Sub cmbstatus_AfterUpdate()
        Compute_Times
    End Sub
    ' **********************************
    '  Update Escalated Date Time
    ' **********************************
    Private Sub txtEscDate_AfterUpdate()
        If txtEscTime = "" Then
            Me.txtEscTime.SetFocus
            GoTo Exit_txtEscDate_AfterUpdate
        
        ElseIf IsNull(txtEscDate) Then
             Me.txtEscTime = ""
             Me.txtEscalated = ""
            
        ElseIf IsDate(txtEscDate) Then
            txtEscalated = txtEscDate + CDate(txtEscTime)
            If txtEscalated > Now Then
                MsgBox "Escalated can not be furture date", vbInformation
                Me.txtEscDate.SetFocus
                GoTo Exit_txtEscDate_AfterUpdate
            
            ElseIf Me.txtCalled > Me.txtEscalated Then
                MsgBox "Escalate can not be before Called", vbInformation
                Me.txtCalled.SetFocus
                GoTo Exit_txtEscDate_AfterUpdate
            End If
        
        End If
        
        Call Compute_Times
        Call Fill_Date_Time_Fields
    Exit_txtEscDate_AfterUpdate:
    End Sub
    Private Sub txtEscTime_AfterUpdate()
        
        If Not IsDate(txtEscDate) Then
            MsgBox "Please enter a valid date", vbInformation
            Me.txtEscDate.SetFocus
            GoTo Exit_txtEscTime_AfterUpdate
        
        ElseIf IsDate(txtEscDate) Then
            txtEscalated = txtEscDate + CDate(txtEscTime)
            If txtEscalated > Now Then
                MsgBox "Escalated Back can not be furture date", vbInformation
                Me.txtEscDate.SetFocus
                GoTo Exit_txtEscTime_AfterUpdate
            
            ElseIf Me.txtCalled > Me.txtEscalated Then
                MsgBox "Escalated can not be before Called", vbInformation
                Me.txtEscDate.SetFocus
                GoTo Exit_txtEscTime_AfterUpdate
            End If
        
        End If
        
        'Call Compute_Times
        Call Fill_Date_Time_Fields
    Exit_txtEscTime_AfterUpdate:
    End Sub
    ' **********************************
    '  Update Called Back Date Time
    ' **********************************
    Private Sub txtCallBackDt_GotFocus()
        
        If IsNull(txtCallBack) Then
    '        If Not IsNull(txtCalled) Then
    '            txtCallBack = txtCalled
    '        End If
        End If
        
        If Not IsNull(txtCallBack) Then
            Me.txtCallBackDt = Int(txtCallBack)
            Me.txtCallBackTm = Format(txtCallBack - Int(txtCallBack), "HH:MM")
            
        End If
    End Sub
    Private Sub txtCallBackDt_AfterUpdate()
        
        If txtCallBackTm = "" Then
            Me.txtCallBackTm.SetFocus
            GoTo Exit_txtCallBackDt_AfterUpdate
        
        ElseIf IsNull(txtCallBackDt) Then
            Me.txtCallBackTm = ""
            Me.CallBack = ""
            
        ElseIf IsDate(txtCallBackDt) Then
            txtCallBack = txtCallBackDt + CDate(txtCallBackTm)
            If txtCallBack > Now Then
                MsgBox "Call back can not be furture date", vbInformation
                Me.txtCallBack.SetFocus
                GoTo Exit_txtCallBackDt_AfterUpdate
            
            ElseIf Me.txtCalled > Me.txtCallBack Then
                MsgBox "Call Back can not be before Called", vbInformation
                Me.txtCallBackDt.SetFocus
                GoTo Exit_txtCallBackDt_AfterUpdate
            End If
        
        End If
        
        Call Compute_Times
        Call Fill_Date_Time_Fields
    Exit_txtCallBackDt_AfterUpdate:
    
    End Sub
    Private Sub txtCallBackTm_AfterUpdate()
        
        If Not IsDate(txtCallBackDt) Then
            MsgBox "Please enter a valid date", vbInformation
            Me.txtCallBackDt.SetFocus
            GoTo Exit_txtCallBackTm_AfterUpdate
        
        ElseIf IsDate(txtCalledDt) Then
            txtCallBack = txtCallBackDt + CDate(txtCallBackTm)
            If txtCallBack > Now Then
                MsgBox "Call Back can not be furture date", vbInformation
                Me.txtCallBackDt.SetFocus
                GoTo Exit_txtCallBackTm_AfterUpdate
            
            ElseIf Me.txtCalled > Me.txtCallBack Then
                MsgBox "Call Back can not before Called", vbInformation
                Me.txtCallBackDt.SetFocus
                GoTo Exit_txtCallBackTm_AfterUpdate
            End If
        
        End If
        
        Call Compute_Times
        Call Fill_Date_Time_Fields
    Exit_txtCallBackTm_AfterUpdate:
    End Sub
    ' **********************************
    '  Update Arrived Date Time
    ' **********************************
    Private Sub txtArrivedDt_GotFocus()
        If IsNull(Me.Arrived) Then
            'Me.Arrived = Me.txtCalled
        End If
        Call Fill_Date_Time_Fields
        
    End Sub
    Private Sub txtArrivedDt_AfterUpdate()
        If Me.txtArrivedTm = "" Then
            Me.txtArrivedTm.SetFocus
            GoTo Exit_txtArrivedDt_AfterUpdate
        ElseIf IsDate(txtArrivedDt) Then
            txtArrived = txtArrivedDt + CDate(txtArrivedTm)
            If Me.txtArrived > Now Then
                MsgBox "Arrived can not be furture date", vbInformation
                Me.txtArrivedDt.SetFocus
                GoTo Exit_txtArrivedDt_AfterUpdate
            ElseIf Me.txtArrived < Me.txtCalled Then
                Me.txtArrivedDt.SetFocus
                MsgBox "Arrived Date must be after Called"
                GoTo Exit_txtArrivedDt_AfterUpdate
            End If
        End If
        Call Compute_Times
        Call Fill_Date_Time_Fields
    Exit_txtArrivedDt_AfterUpdate:
    End Sub
    Private Sub txtArrivedTm_AfterUpdate()
        If Not IsDate(txtArrivedDt) Then
            MsgBox "Please enter a valid date", vbInformation
            Me.txtArrivedDt.SetFocus
            GoTo Exit_txtArrivedTm_AfterUpdate
        ElseIf IsDate(txtArrivedTm) Then
            txtArrived = txtArrivedDt + txtArrivedTm
            If Me.txtArrived > Now Then
                MsgBox "Arrived can not be furture date", vbInformation
                Me.txtArrivedDt.SetFocus
                GoTo Exit_txtArrivedTm_AfterUpdate
            ElseIf Me.txtArrived < Me.txtCalled Then
                Me.txtArrivedDt.SetFocus
                MsgBox "Arrived Date must be after Called"
                GoTo Exit_txtArrivedTm_AfterUpdate
            End If
        End If
        Call Compute_Times
        Call Fill_Date_Time_Fields
    Exit_txtArrivedTm_AfterUpdate:
    End Sub
    
    ' **********************************
    '  Update Repair Start Date Time
    ' **********************************
    Private Sub txtStartDt_GotFocus()
        If IsNull(Me.txtStartDt) Then
    '        Me.Repair_Started = Me.txtArrived
        End If
        Call Fill_Date_Time_Fields
    End Sub
    Private Sub txtStartDt_AfterUpdate()
        
        If Not IsDate(Me.txtStartTm) Then
            Me.txtStartTm.SetFocus
            GoTo Exit_txtStartDt_AfterUpdate
       
        ElseIf IsDate(txtStartDt) And IsDate(txtStartTm) Then
            txtRepair_Started = txtStartDt + CDate(txtStartTm)
            If txtRepair_Started > Now Then
                MsgBox "Started can not be furture date", vbInformation
                Me.txtStartDt.SetFocus
                GoTo Exit_txtStartDt_AfterUpdate
            
            ElseIf Me.txtArrived < Me.txtCalled Then
                MsgBox "Start Date must be after Called"
                Me.txtStartDt.SetFocus
                GoTo Exit_txtStartDt_AfterUpdate
            
            End If
        End If
        Call Compute_Times
    Exit_txtStartDt_AfterUpdate:
        
    End Sub
    Private Sub txtStartTm_AfterUpdate()
        
        If Not IsDate(Me.txtStartDt) Then
            MsgBox "Please enter a valid date", vbInformation
            Me.txtStartTm.SetFocus
            GoTo Exit_txtStartTm_AfterUpdate
        
        ElseIf IsDate(txtStartTm) Then
            txtRepair_Started = txtStartDt + txtStartTm
            If txtRepair_Started > Now Then
                MsgBox "Started can not be furture date", vbInformation
                Me.txtStartDt.SetFocus
                GoTo Exit_txtStartTm_AfterUpdate
            
            ElseIf Me.txtArrived < Me.txtCalled Then
                MsgBox "Start Date must be after Called"
                Me.txtStartDt.SetFocus
                GoTo Exit_txtStartTm_AfterUpdate
            
            End If
        End If
        
        Call Compute_Times
        
    Exit_txtStartTm_AfterUpdate:
    End Sub
    ' **********************************
    '  Update Repair End Date Time
    ' **********************************
    Private Sub txtEndDt_GotFocus()
        If IsNull(Me.txtEndDt) Then
    '        Me.txtRepair_End = txtRepair_Started
        End If
        Call Fill_Date_Time_Fields
        
    End Sub
    Private Sub txtEndDt_AfterUpdate()
            
        If IsNull(txtEndDt) Then
            Me.txtEndTm = ""
            Repair_End = Null
            GoTo Exit_txtEndDt_AfterUpdate
        End If
            
        If Not IsDate(Me.txtEndTm) Then
            Me.txtEndTm.SetFocus
            
        ElseIf IsDate(txtEndDt) Then
            txtRepair_End = txtEndDt + CDate(txtEndTm)
            If Me.txtRepair_End > Now Then
                MsgBox "Completed can not be furture date", vbInformation
                Me.txtEndDt.SetFocus
                GoTo Exit_txtEndDt_AfterUpdate
            
            ElseIf txtRepair_End < txtRepair_Started Then
                MsgBox "End Date must be after Start"
                Me.txtEndDt.SetFocus
                GoTo Exit_txtEndDt_AfterUpdate
            
            End If
        End If
        
        Call Compute_Times
        
    Exit_txtEndDt_AfterUpdate:
    End Sub
    Private Sub txtEndTm_AfterUpdate()
        
        If Not IsDate(Me.txtEndDt) Then
            MsgBox "Please enter a valid date", vbInformation
            Me.txtEndDt.SetFocus
            GoTo Exit_txtEndTm_AfterUpdate
            
        ElseIf IsDate(txtEndTm) Then
            txtRepair_End = txtEndDt + txtEndTm
            If Me.txtRepair_End > Now Then
                MsgBox "Completed can not be furture date", vbInformation
                Me.txtEndDt.SetFocus
                GoTo Exit_txtEndTm_AfterUpdate
            
            ElseIf txtRepair_End < txtRepair_Started Then
                MsgBox "End Date must be after Start"
                Me.txtEndDt.SetFocus
                GoTo Exit_txtEndTm_AfterUpdate
            
            End If
            
        End If
        Call Compute_Times
    Exit_txtEndTm_AfterUpdate:
        
    End Sub
    ' **********************************************
    ' ** Button click code
    ' **********************************************
    Private Sub btnErrorLog_Click()
        If Not Validate_Data Then
        
        Else
            DoCmd.OpenForm "Error_list", , , , , , Me.cmbPrinter
        End If
        'DoCmd.OpenForm "Error_list", , , , , , Me.cmbPrinter
        
    End Sub
    Private Sub BtnAdd_Click()
        If Not Validate_Data Then
           Cancel = True
           GoTo Exit_BtnAdd_Click
        End If
        
        DoCmd.GoToRecord , , acNewRec
        
        Me.txtLog_Key = GetNextNumber("Laser_Maint_Log", "Log_Key", 1)
        Me.txtLog_Date = Now
                
        Me.txtErrorDesc = ""
        
        If IsNull(Me.cmbPrinter) Then
           Me.cmbPrinter = Me.cmbPrinter.ItemData(0)
        End If
        
        Me.btnDelete.Visible = False
        Me.cmbOperator.SetFocus
        Me.btnAdd.Visible = False
        Hide_Navigation
        
    Exit_BtnAdd_Click:
    End Sub
    Private Sub btnClose_Click()
        If Not Validate_Data Then
           Cancel = True
           GoTo Exit_btnClose_Click
        End If
        
        If Me.Dirty Then
            If MsgBox("Save before closing?", vbYesNo, "Confirm") = vbYes Then
                If Validate_Data Then
                    DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
                Else
                    GoTo Exit_btnClose_Click
                End If
            Else
                Me.Undo
            End If
        End If
        
        DoCmd.Close
    Exit_btnClose_Click:
    End Sub
    Private Sub Fill_Date_Time_Fields()
    ' *******************************************************
    ' *** fill the Date Time fields
    ' *******************************************************
        If Not IsNull(txtCalled) Then
            Me.txtCalledDt = Int(txtCalled)
            'Me.txtCalledTm = Format(txtCalled - Int(txtCalled), "HH:MM")
            Me.txtCalledTm = txtCalled - Int(txtCalled)
        Else
            Me.txtCalledDt = ""
            Me.txtCalledTm = ""
        End If
        
        If Not IsNull(txtEscalated) Then
            Me.txtEscDate = Int(txtEscalated)
            Me.txtEscTime = txtEscalated - Int(txtEscalated)
        Else
            Me.txtEscDate = ""
            Me.txtEscTime = ""
        End If
        
        If Not IsNull(txtCallBack) Then
            Me.txtCallBackDt = Int(txtCallBack)
            'Me.txtCallBackTm = Format(txtCallBack - Int(txtCallBack), "HH:MM")
            Me.txtCallBackTm = txtCallBack - Int(txtCallBack)
        Else
            Me.txtCallBackDt = ""
            Me.txtCallBackTm = ""
        End If
        
        If Not IsNull(txtArrived) Then
            Me.txtArrivedDt = Int(txtArrived)
            'Me.txtArrivedTm = Format(txtArrived - Int(txtArrived), "HH:MM")
            Me.txtArrivedTm = txtArrived - Int(txtArrived)
        Else
            Me.txtArrivedDt = ""
            Me.txtArrivedTm = ""
        End If
        
        If Not IsNull(Repair_Started) Then
            Me.txtStartDt = Int(Repair_Started)
            'Me.txtStartTm = Format(Repair_Started - Int(Repair_Started), "HH:MM")
            Me.txtStartTm = Repair_Started - Int(Repair_Started)
        Else
            Me.txtStartDt = ""
            Me.txtStartTm = ""
        End If
        If Not IsNull(Repair_End) Then
            Me.txtEndDt = Int(Me.Repair_End)
            'Me.txtEndTm = Format(Me.Repair_End - Int(Me.Repair_End), "HH:MM")
            Me.txtEndTm = Me.Repair_End - Int(Me.Repair_End)
        Else
            Me.txtEndDt = ""
            Me.txtEndTm = ""
        End If
        
    End Sub
    Private Sub Compute_Times()
    ' *******************************************************
    ' *** Compute the lapsed times fields
    ' *******************************************************
        If IsNull(Me.txtCalled) _
        Or IsNull(Me.txtArrived) Then
            txtResponce = 0
        Else
            txtTimeElpsd = ElapsedTimeString(Me.txtCalled, txtArrived, "S")
            SplitArgs = Split(txtTimeElpsd, ";")
            If SplitArgs(0) > "" Then
                Me.txtResponce.Value = SplitArgs(0)
            End If
        End If
        
        If IsNull(Me.txtRepair_Started) _
        Or IsNull(Me.txtRepair_End) Then
            txtRepair = 0
        Else
            txtTimeElpsd = ElapsedTimeString(Me.Repair_Started, Me.txtRepair_End, "S")
            SplitArgs = Split(txtTimeElpsd, ";")
            If SplitArgs(0) > "" Then
                txtRepair = SplitArgs(0)
            End If
        End If
        
        If Me.cmbStatus = "Down" Then
            If IsNull(Me.Called) _
            Or IsNull(Me.txtRepair_End) Then
                txtDown = 0
            Else
                txtTimeElpsd = ElapsedTimeString(Me.Called, Me.txtRepair_End, "S")
                SplitArgs = Split(txtTimeElpsd, ";")
                If SplitArgs(0) > "" Then
                    txtDown = SplitArgs(0)
                End If
            End If
        Else
            If IsNull(Me.Repair_Started) _
            Or IsNull(Me.txtRepair_End) Then
                txtDown = 0
            Else
                txtTimeElpsd = ElapsedTimeString(Me.Repair_Started, Me.txtRepair_End, "S")
                SplitArgs = Split(txtTimeElpsd, ";")
                If SplitArgs(0) > "" Then
                    txtDown = SplitArgs(0)
                End If
            End If
        End If
    End Sub
    Private Function Validate_Data()
        Validate_Data = True
    ' ************************************************
    ' ** Every record is required to have these fields
    ' ************************************************
        If IsNull(Me.cmbOperator) Then
            MsgBox "Operator is required", vbCritical
            Me.cmbOperator.SetFocus
            Validate_Data = False
        ElseIf Not IsDate(Me.txtLog_Date) Then
            MsgBox "Valid date is required", vbCritical
            Me.txtLog_Date.SetFocus
            Validate_Data = False
        ElseIf IsNull(Me.cmbPrinter) Then
            MsgBox "Printer is required", vbCritical
            Me.cmbPrinter.SetFocus
            Validate_Data = False
         ElseIf IsNull(Me.txtCalled) Then
            MsgBox "Service Call Date required"
            Me.txtCalledDt.SetFocus
            Validate_Data = False
            
        ElseIf IsNull(Me.cmbStatus) Then
            MsgBox "Status is required"
            Me.cmbStatus.SetFocus
            Validate_Data = False
        
         ElseIf IsNull(Me.txtMeter) Then
            MsgBox "Meter is required"
            Me.txtMeter.SetFocus
            Validate_Data = False
       
        End If
        
        If Not Validate_Data Then GoTo Exit_Validate_Data
        If IsDate(Me.txtCallBack) _
        And IsNull(Call_Action) Then
            MsgBox "Please fill out the responce field"
            Me.Call_Action.SetFocus
            Validate_Data = False
            GoTo Exit_Validate_Data
        End If
            
        If IsDate(Me.txtArrived) Then
            If Me.txtArrived > Now Then
                MsgBox "Arrived can not be furture date"
                Me.txtStartDt.SetFocus
                Validate_Data = False
                GoTo Exit_Validate_Data
            End If
        
            If IsNull(Me.cmbTech_Name) Then
                MsgBox "Please enter a Tech Name"
                Me.cmbTech_Name.SetFocus
                Validate_Data = False
                GoTo Exit_Validate_Data
            End If
        End If
        If IsDate(Me.Repair_Started) _
        And Me.Repair_Started > Now Then
            MsgBox "Start date can not be furture date"
            Me.txtStartDt.SetFocus
            Validate_Data = False
            GoTo Exit_Validate_Data
        End If
        
        If IsDate(Me.txtRepair_End) Then
            If Validate_Close = False Then
                Validate_Data = False
            End If
        End If
    Exit_Validate_Data:
    End Function
            
    Private Function Validate_Close() As Boolean
        
        Validate_Close = True
    '  *******************************************
    '  *** Time calulations require these Fields
    '  *** Responce = Called to Arrived
    '  *** Repair =
    '  ***     Status "Down" = Called to Ended
    '  ***              "up" = Started to Ended
    '  *******************************************
        If Me.txtRepair_End > Now Then
            MsgBox "Completed date can not be furture date"
            Me.txtEndDt.SetFocus
            Validate_Close = False
            
        ElseIf Not IsDate(Me.txtArrived) Then
            MsgBox "Please Enter Arived date if tech was on stie enter called date"
            Me.txtRepair_Action.SetFocus
            Validate_Close = False
        
        ElseIf Not IsDate(Me.Repair_Started) Then
            MsgBox "Please Enter valid Start date"
            Me.txtRepair_Action.SetFocus
            Validate_Close = False
        
        ElseIf IsNull(Me.txtRepair_Action) Then
            MsgBox "Please discribe the repair action"
            Me.txtRepair_Action.SetFocus
            Validate_Close = False
        
        ElseIf IsNull(Me.cmbTech_Name) Then
            MsgBox "Tech name is required"
            Me.cmbTech_Name.SetFocus
            Validate_Close = False
        
        ElseIf IsNull(Me.cmbReceivedBy) Then
            MsgBox "Received by is required"
            Me.cmbReceivedBy.SetFocus
            Validate_Close = False
            
        End If
    End Function
    Private Sub Hide_Navigation()
        Me.Text130.Visible = False
        Me.cmdFirst.Visible = False
        Me.cmdPrevious.Visible = False
        Me.txtItemCount.Visible = False
        Me.cmdNext.Visible = False
        Me.cmdLast.Visible = False
        Me.txtInfo.Visible = False
        
    End Sub
    Private Sub Show_Navigation()
        Me.cmdFirst.Enabled = True
        Me.cmdPrevious.Enabled = True
        Me.cmdNext.Enabled = True
        Me.cmdLast.Enabled = True
        
        Me.Recordset.MoveFirst
        
        intIndex = Me.Recordset.AbsolutePosition + 1
        intCount = Me.Recordset.RecordCount
        
         Me.txtItemCount = intIndex & " of " & intCount
    End Sub
    Private Sub cmdFirst_Click()
        If Validate_Data Then
            DoCmd.GoToRecord , , acFirst
        End If
    End Sub
    Private Sub cmdPrevious_Click()
        If Validate_Data Then
            DoCmd.GoToRecord , , acPrevious
        End If
    End Sub
    Private Sub cmdNext_Click()
        If Validate_Data Then
            DoCmd.GoToRecord , , acNext
        End If
    End Sub
    Private Sub cmdLast_Click()
        If Validate_Data Then
            DoCmd.GoToRecord , , acLast
        End If
    End Sub

  5. #5
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2013 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    This is certainly not obvious! Post your db if you wish.

  6. #6
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,511
    Delete the current combo box control and create a new one with the 4 values and name it the same. Could just be an access glitch. Or use a table instead of typing in the values.

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

Similar Threads

  1. Alter Table, YES/NO field
    By gmaster in forum Queries
    Replies: 1
    Last Post: 10-29-2014, 03:25 AM
  2. Replies: 4
    Last Post: 10-21-2013, 11:06 AM
  3. Replies: 1
    Last Post: 10-03-2012, 04:12 PM
  4. Replies: 1
    Last Post: 03-27-2012, 07:10 AM
  5. Alter table Yes/No field
    By Cojack in forum Queries
    Replies: 7
    Last Post: 10-27-2010, 11:31 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