Apologies for butting in...
I have a situation similar to your problem
where I have used the following method
(maybe it will help)
I have a table "tblTextbookOrderWorksheet"
A form is based on a query into this table "qryTOW"
I made a copy of "tblTextbookOrderWorksheet"
and called it "tblTOWBlank"
I went through design of "tblTOWBlank" and allowed
all fields to be "blank" then set it up with one "blank"
record (one inconsequential field had a value).
I then made a copy of "qryTOW" calling it "qryTOWBlank"
and made it use "tblTOWBlank" instead of "tblTOW"
So, on this form I have a command button where the user
can get a new Term, i.e., fill "tblTextbookOrderWorksheet"
with data from a different Term.
Private Sub cmdProcessAnotherTerm_Click()
On Error GoTo Err_cmdProcessAnotherTerm_Click
Dim strDocName As String
'unlink recordsource
Me.RecordSource = "qryTOWBlank"
Me.Requery
'open modal form to get data for new Term
strDocName = "frmProcessAnotherTerm"
DoCmd.OpenForm stDocName, acNormal, , , , acDialog
'relink to new data now in "tblTextbookOrderWorksheet"
Me.RecordSource = "qryTOW"
Me.Requery
Exit_cmdProcessAnotherTerm_Click:
Exit Sub
Err_cmdProcessAnotherTerm_Click:
MsgBox Err.Description
Resume Exit_cmdProcessAnotherTerm_Click
End Sub
I've left out a lot that was irrelevant to your situation
(like recordsources of subforms and various controls
and other error checking). And I know you will not
need to open another modal form to change contents
of table.
At a minimum, you could replace from above code
'open modal form to get data for new Term
strDocName = "frmProcessAnotherTerm"
DoCmd.OpenForm stDocName, acNormal, , , , acDialog
with executing your make table query
DoCmd.RunSQL "Final_Top10_Points_A"
As John pointed out, typically one would change
your query to an append query, then empty table,
then run append query. If the name of your table
was "t1" and the append query was "qryappend"
(and you have set reference to DAO in References)
CurrentDb.Execute "DELETE * FROM t1", dbFailOnError
CurrentDb.Execute "qryappend", dbFailOnError
efandango said:
John Vinson said:
ANd you gt the error when you click the button?
Evidently the query (which I cannot see from here)
Final_Top10_Points_A is attempting to modify data in a recordset which
is already open on your form (which I also cannot see from here).
You MUST - no options, sorry! - either close the Form or change its
Recordsource to blank in order to run a query which will modify the
records which the form is displaying.
John W. Vinson[MVP]
John,
I'm slightly confused. I believe i have done what you suggested, which was
to clear out (delete) the host query, then make an append query. You said
you
don't think i will have to close the form in order to do so, but now you
seem
100% definate that I will have to close the form.
Here is the mechanics of the queries/process.
The table 'Final Top10A' is what I use to populate the form
Delete Top 10 Points A
(This is the Query that clears the table 'Final Top10A'.
DELETE [Final Top10A].Run_No, [Final Top10A].Point_Quiz_ID, [Final
Top10A].Run_point_Venue_A, [Final Top10A].Run_point_Address_A
FROM [Final Top10A];
Final_Top10_Points_A
(This is the Query that populates the table 'Final Top10A'.)
INSERT INTO [Final Top10A] ( Run_No, Point_Quiz_ID, Run_point_Venue_A,
Run_point_Address_A )
SELECT [Top 10 Points generator].Run_No, [Top 10 Points
generator].Point_Quiz_ID, [Top 10 Points generator].Run_point_Venue_A,
[Top
10 Points generator].Run_point_Address_A
FROM [Top 10 Points generator];
If it is definately the case that I cannot do this while the form is open;
then is there another process that I can use to enable me to update a
table
based form with the contents of a query based table, based on a random
selection of records taken from a master table.
regards
Eric