Dan Waters
dwaters at usinternet.com
Tue Mar 20 08:33:12 CDT 2007
Hi Tom, This is something you can try: Change the 2nd to last line of code to: [Forms].[frmassemblies].[sfrmPartAssy].Form.Requery Hope this helps calculating CG! Dan Waters -----Original Message----- Subject: [AccessD] Subform data disappears on addition I have a form (frmAssemblies) with a subform (sfrmPartAssy). The main form displays the main assembly table data (for one assembly), while the subform displays data from a query that combines the data from a parts (tblParts) table and the junction table (tblPartAssy) between the two, showing the applicable parts in the assembly shown in the main form. I have a button on the main form that adds parts to the assembly; below is the code. -------------------- Private Sub cmdAdd_Click() Dim strSQL strSQL = "INSERT INTO tblPartAssy SELECT " & _ "[Forms]![frmAssemblies]![cboAssy] AS Assy, " & _ "[Forms]![frmAssemblies]![cboRev] AS Rev, " & _ "[Forms]![frmAddPartAssy]![cboPartNum] AS PartNum, " & _ "[Forms]![frmAddPartAssy]![txtQuantity] AS Qty, " & _ "[Forms]![frmAddPartAssy]![txtFindNum] AS FindNum;" DoCmd.SetWarnings False DoCmd.RunSQL (strSQL) DoCmd.SetWarnings True [Forms]![frmassemblies].Requery [Forms]![frmassemblies].[sfrmPartAssy].Requery [Forms]![frmassemblies].Refresh End Sub --------------------- Anyway, the problem is that when I add a part to the assembly, all of the data in the subform disappears; if I then go to another assembly, and then return to the original one, the data reappears, along with the added part. This happens for all assemblies EXCEPT the first one in the tblASSSEMBLIES table. I'm fuzzy on the requery/refresh thing, so I tend to overuse them, just to be safe. Perhaps I'm causing a problem with that? Since the data IS entered, the process does work, but having the subform's data disappear is a major irritation. Any suggestions on this would be appreciated. Thomas F. Ewald Stryker Mass Properties General Dynamics Land Systems This is an e-mail from General Dynamics Land Systems. It is for the intended recipient only and may contain confidential and privileged information. No one else may read, print, store, copy, forward or act in reliance on it or its attachments. If you are not the intended recipient, please return this message to the sender and delete the message and any attachments from your computer. Your cooperation is appreciated. -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com