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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

setting a subform to Add New record from another subform

Status
Not open for further replies.

zevw

MIS
Jul 3, 2001
697
US
Basically I have a Main Form with 2 SubForms and I bookmark the first subforms recordset (called InvSubForm) to the value of InvNo in the second subform which I am in presently. Two issues arise!

1. When the main form opens it gives me an error the it cannot find the form/property. I therefore added the "On Error Resume Next", because once the form is open I can move around and it will bookmark the first subform to the proper value. I was wondering if there is way without the On Error to correct this.

2. IS AN URGENT MATTER
In the last ELSE of the condition (code below) if the field InvNo in the current record is null, I want to set the subform number 1 (called InvSubForm) to add a new record. I tried many different ways, but nothing seems to work. I don't know how to unset the recordset from the previous bookmark or how to move it to a new record.

Any help is appreciatted!
Code:
Private Sub Form_Current()
    
On Error Resume Next
If Nz(Me.InvNo, "") <> "" Then
   Forms!POFnlForm!InvSubform.Form.RecordsetClone.FindFirst "[InvNo] ='" & Nz(Me.InvNo, "") & "'"
   Forms!POFnlForm!InvSubform.Form.Bookmark = Forms!POFnlForm!InvSubform.Form.RecordsetClone.Bookmark
ElseIf Nz(Me.InvNo, "") = "" And Nz(Forms!POFnlForm!InvSubform.Form.NewInvNo.Tag, "") <> "" Then
   Forms!POFnlForm!Invoicesubform.Form.RecordsetClone.FindFirst "[InvoiceNo] = '" & Forms!POFnlForm!Invoicesubform.Form.NewInvNo.Tag & "'"
   Forms!POFnlForm!Invoicesubform.Form.Bookmark = Forms!POFnlForm!Invoicesubform.Form.RecordsetClone.Bookmark
Else
   Forms!POFnlForm!Invoicesubform.Form.SetFocus
   DoCmd.GoToRecord , , acNewRec
End If

End Sub
 
How are ya zevw . . .

Your overall table/form structure is hard to see. No one can really help until this brought to the forefront. Besides I cringed on a few of the sentences. [surprise]
[ol][li]What are the [blue]names[/blue] of the [blue]tables[/blue] involved in the [blue]recordsource property[/blue] of the [blue]mainform & subforms[/blue].[/li]
[li]Whats the [blue]relationships of the tables[/blue] (who's on the one side, who's on the many, name & datatype of linking fields)?[/li]
[li]Whats the [blue]name[/blue] of the mainform & subforms & their [blue]source tables?[/blue][/li]
[li]How are the subforms nested? . . . Are both subforms nested on the mainform or is sunform2 nested on subform1 which is nested on the mainform?[/li][/ol]
Answering these questions will open the door! [thumbsup2]

[blue]Your Thoughts? . . .[/blue]

Calvin.gif
See Ya! . . . . . .
 
Thanks for responding I am really having a hard time with this.

1.
There are 3 tables POs, PODtl and Invoices

2.
Main Form and Subform2 are related One to Many by PONum.
Subform1 is not related to anything. The reason for that, is because the newer records in PoDtl don't yet have a invoice number.

3.
The Main Form recordsource is POS
SubForm1 is Invoices
SubForm2 is PoDtl

4.
The 2 subforms are nested in the main form.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top