Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help on my Code!

Status
Not open for further replies.

Tash

MIS
Nov 3, 2001
62
0
0
US
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
 
Maybe something like:
[tt]If Me.SubformGenerateInv.Form.RecordsetClone.RecordCount = 0 Then[/tt]
 
Thanks for the suggestion, but it is still not working. Pretty much the same result.
 
I do not think that
With CodeContextObject
can work in this situation, you need to say, (starting back a line):
[tt]If Me.SubformGenerateInv.Form.Recordset.RecordCount = 0 Then
With Me.SubformGenerateInv.Form[/tt]


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top