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

Subform Problem - ADP Database (MSDE Back-End)

Status
Not open for further replies.

mmansfield

Programmer
Mar 28, 2000
3
US
I have an invoice header/invoice detail type form.&nbsp;&nbsp;I'm using bound fields.&nbsp;&nbsp;Form opens in and works OK in data entry mode.&nbsp;&nbsp;For edits, I have a field in which the user enters an invoice #.&nbsp;&nbsp;In the after update method of this field, I change the recordsources of the parent and child tables to:&nbsp;&nbsp;SELECT * from &lt; &gt; for invoicenum=?&lt;# specified by user&gt;.&nbsp;&nbsp;This works ok too - the form retrieves the desired record, the subform is populated properly - I can change any of the parent or child records.&nbsp;&nbsp;I run into a problem though when I try to add a new child record.&nbsp;&nbsp;I get the error message:<br>&quot;The data was added to the database but the data won't be displayed on the form because it doesn't satisfy the criteria in the underlying record source&quot;.&nbsp;&nbsp;My subform adds the foreign key in the before-update event.&nbsp;&nbsp;The subform record IS added properly.&nbsp;&nbsp;You can close the form, call up the invoice and the new child record is there.&nbsp;&nbsp;You just can't see it in the session in which it was created.<br><br>This is my first attempt at an ADP.&nbsp;&nbsp;Has anyone else seen<br>this and know how to work-around?<br><br>Any help would be greatly appreciated.
 
If your new record does not meet the criteria then you have to refresh the data source.<br>If you don't want to see the error message.<br>Try this<br>Add the new record through VBA code<br> Dim db as database, rst as recordset, SQL as string<br> Set db = CurrentDb<br> set rst = db.OpenRecordset(&quot;Tablename&quot;)<br>rst.addnew<br>rst!Yourfield= me!Textbox1<br>'put all fields here<br>rst.update<br>rst.close<br>db.close<br><br>'then requery the record source of the subform.<br>Me![SupplierandParts subform].Requery<br>
 
I love Access. <br><br>Try this guy (executed from the sub form) after the sub forms save macro executes.<br>&nbsp;<br><b> Forms![mainformname].Refresh </b><br> <p>Amiel<br><a href=mailto:amielzz@netscape.net>amielzz@netscape.net</a><br><a href= > </a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top