Update a date field in sub-form from dates fields on main form

  • Thread starter Thread starter DaveJJ
  • Start date Start date
D

DaveJJ

The the following code is from the after update event of a combo box
referencing the column(1) data, not the column (0) ID data. I am
trying to populate a date field on a sub-form from date fields on the
main form. It doesn't work, what am I doing wrong?

Private Sub cmbOperations_AfterUpdate()

Dim str1 As String

str1 = Me.cmbOperations.Column(1)

If str1 = Left(str1, 2) = "WX" And IsNull(Forms!frmCustomMain!
txtDateWaxToComplete) = False _
And IsNull(Me.txtDueDate) = True Then
Me.txtDueDate = Forms!frmCustomMain!txtDateWaxToComplete
ElseIf str1 = Left(str1, 2) = "CA" And IsNull(Forms!frmCustomMain!
txtDateToCast) = False _
And IsNull(Me.txtDueDate) = True Then
Me.txtDueDate = Forms!frmCustomMain!txtDateToCast
ElseIf str1 = Left(str1, 2) = "BN" And IsNull(Forms!frmCustomMain!
txtDateToQCprojected) = False _
And IsNull(Me.txtDueDate) = True Then
Me.txtDueDate = Forms!frmCustomMain!txtDateToQCprojected
ElseIf str1 = Left(str1, 2) = "CT" And IsNull(Forms!frmCustomMain!
txtDateToQCprojected) = False _
And IsNull(Me.txtDueDate) = True Then
Me.txtDueDate = Forms!frmCustomMain!txtDateToQCprojected
Else
Exit Sub
End If

End Sub
 
The the following code is from the after update event of a combo box
referencing the column(1) data, not the column (0) ID data.  I am
trying to populate a date field on a sub-form from date fields on the
main form.  It doesn't work, what am I doing wrong?

Private Sub cmbOperations_AfterUpdate()

Dim str1 As String

    str1 = Me.cmbOperations.Column(1)

    If str1 = Left(str1, 2) = "WX" And IsNull(Forms!frmCustomMain!
txtDateWaxToComplete) = False _
        And IsNull(Me.txtDueDate) = True Then
        Me.txtDueDate = Forms!frmCustomMain!txtDateWaxToComplete
    ElseIf str1 = Left(str1, 2) = "CA" And IsNull(Forms!frmCustomMain!
txtDateToCast) = False _
        And IsNull(Me.txtDueDate) = True Then
        Me.txtDueDate = Forms!frmCustomMain!txtDateToCast
    ElseIf str1 = Left(str1, 2) = "BN" And IsNull(Forms!frmCustomMain!
txtDateToQCprojected) = False _
        And IsNull(Me.txtDueDate) = True Then
        Me.txtDueDate = Forms!frmCustomMain!txtDateToQCprojected
    ElseIf str1 = Left(str1, 2) = "CT" And IsNull(Forms!frmCustomMain!
txtDateToQCprojected) = False _
        And IsNull(Me.txtDueDate) = True Then
        Me.txtDueDate = Forms!frmCustomMain!txtDateToQCprojected
    Else
        Exit Sub
    End If

End Sub

Figured it out - problem is: str1 = Left(str1, 2)
should simply be: Left(str1, 2)
 
Back
Top