I have some code that puts data from my Main form to my subform. Everything in the code is working great, however, I would like to put a clause in the code that says if my Subform fields already have data, to abort the whole code. When I put in the following code, nothing happens when I execute the code. This is what I have. The line I am having trouble with is [If IsNull(Me.SubformGenerateInv.Form.Recordset) Then] Please help!
Private Sub cmdAssign_Click()
If IsNull(Me.SubformGenerateInv.Form.Recordset) Then
With CodeContextObject
.InvStartDate = Forms!FormPrintInvoice!EnterBeginningDate
.InvEndDate = Forms!FormPrintInvoice!EnterEndDate
.InvStore = Forms!FormPrintInvoice!Enterstore
End With
Dim intInvoiceID As Long
Dim rsRecordsToAssign As DAO.Recordset
If Not IsNull(Me.autoInvoiceID) Then
intInvoiceID = Me.autoInvoiceID
Set rsRecordsToAssign = Me.SubformGenerateInv.Form.Recordset
Do While Not rsRecordsToAssign.EOF
rsRecordsToAssign.Edit
rsRecordsToAssign.Fields("InvoiceNumber") = autoInvoiceID
rsRecordsToAssign.Update
rsRecordsToAssign.MoveNext
Loop
MsgBox "Records Assigned"
Else
MsgBox "These Records have already been assigned an Invoice Number"
End If
End If
End Sub
Private Sub cmdAssign_Click()
If IsNull(Me.SubformGenerateInv.Form.Recordset) Then
With CodeContextObject
.InvStartDate = Forms!FormPrintInvoice!EnterBeginningDate
.InvEndDate = Forms!FormPrintInvoice!EnterEndDate
.InvStore = Forms!FormPrintInvoice!Enterstore
End With
Dim intInvoiceID As Long
Dim rsRecordsToAssign As DAO.Recordset
If Not IsNull(Me.autoInvoiceID) Then
intInvoiceID = Me.autoInvoiceID
Set rsRecordsToAssign = Me.SubformGenerateInv.Form.Recordset
Do While Not rsRecordsToAssign.EOF
rsRecordsToAssign.Edit
rsRecordsToAssign.Fields("InvoiceNumber") = autoInvoiceID
rsRecordsToAssign.Update
rsRecordsToAssign.MoveNext
Loop
MsgBox "Records Assigned"
Else
MsgBox "These Records have already been assigned an Invoice Number"
End If
End If
End Sub