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

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
 
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

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top