My first Form based on a Query

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have managed to write my first form based on a query, however when I add a
new record to the table and subsequently try to view the record it is not
there (even though it is in the Table. I assume that I need to update the
query when I have written the record and also assume that it should be done
via "DoCmd.Requery".
Would the command syntax be something like "DoCmd.Requery "tbl_Stock" where
tbl_Stock is the Table I have just written the record to?
Thanks RayC
 
Ray,

Are you literally entering the new record directly to the table? If you
open the query that the form is based on, do you see the new record in
the query datasheet? If so, if you close the form and open it again, do
you then see the newly added record? Does that mean that you are
entering the new record to the table while the form is open? If so,
this is a rather irregular way of doing things, as one would normally
expect that the new record would be entered via a form, or the form.

Sorry, more questions than answers. But clarification neded, I think,
before a good answer can be given.
 
I have managed to write my first form based on a query, however when I add a new record to the table and subsequently try to view the record it is not there

Ray,
Keep in mind that your form is just a user-friendly version of a query datasheet. A query, by definition, is a question that you have asked MS Access....does your newest entry satisfy all the criteria set for your query?? If it doesn't, you won't see the record in your form. It sounds as though this may be the issue.

The reason you can see the newest record in your table is because a query (in datasheet view) is also just a portion of your table, or multiple tables, but it IS still part of the table (in other words, it is "linked" to your table). Thus, an entry into a query-based form is the same as an entry into the underlying table.
 
Last edited:
Hi Steve
I have my form that is based on a query, I search the Table for a Record
and that is either found and displayed or not found. If it is not found I ask
if the user wants to enter a new record. This is done in the same Form that
is used to search for the item. The user enters the Record information and
saves the record. If I search for the newly entered record after the record
is saved, the search returns False and says it does not exist. If I open the
query, the record is there in the query. If I open the Table, the record is
there in the table. If I do another search for the record the search returns
False still. If I shut down the database and re open it, and then do the same
search I was doing previously, the search finds the Recorsd with no problem.
I was thinking that the search is done within a Recordset and I though that
the "AddNew" (which works and saves the record) might not update the
recordset or something like that.

Regards RayC
 
After adding the new record and closing the recordset, requery.

Look in Access Help for the Requery method. They have a pretty good
example that shows what's going on.

HTH
 
Hi

I tried putting "DoCmd.Requery" after the save "Update" and before closing
the recordset and that seems to work fine. Thanks for your valuable help

RayC
 
You're welcome. :-)

--
-Larry-
--

Ray C said:
Hi

I tried putting "DoCmd.Requery" after the save "Update" and before closing
the recordset and that seems to work fine. Thanks for your valuable help

RayC
 
Back
Top