Solved

Unable to add or edit records using form

Posted on 2011-03-02
3
389 Views
Last Modified: 2013-11-28
The form's control is a query, which links two other queries.  The query works fine, but it as well as the form does not permit adding or editing records.  Previously, I used a simpler query for the form, a query that links two tables; and this one allows adding and editing records.  I needed an additional link to include another field, though, so created the new query based on two other queries.  I preferred not using a subform to obtain the additional field, but maybe this is the only solution?  By the way, I am not knowledgable for using VB.  Thanks. --PR
0
Comment
Question by:Tucker22
3 Comments
 
LVL 14

Accepted Solution

by:
pteranodon72 earned 500 total points
ID: 35020983
If the query is non-editable, the form cannot change it.

You can drop the extra table from the query's recordsource and still keep a calculated field on the form. You don't mention any field names.
Let's assume your form is based on tblMain and has a numeric ID that links it to qry1. The target field is Target in qry1.

Add a textbox to your form. In the ControlSource property use:

=DLookup("Target", "qry1", "ID = " & [ID])

The first argument is the target field name, the second is domain (table or query name), and the third is a WHERE clause without the word WHERE. The first half is the name of the foreign key field in qry1 and the second half is the name of the field
on your form.

If the fields that link are text, you need to surround the form's value with apostrophes before concatenating it.

HTH,
pT72
0
 
LVL 8

Expert Comment

by:Andrew_Webster
ID: 35023949
Try setting the form's RecordsetType property to Dynaset (Inconsistent Updates).

If that doesn't work, then you'll have to revisit the design of the underlying query.  If the query includes any kind of aggregation (SUM, MAX, etc) then it won't be editable.  If it joins three tables in a many:one:many relationship, they it won't be editable.

If the query joins one:one, you'll be fine.  If it joins one:many and you include the foreign key on the many side, then you *should* be ok.  Setting the Recordset property as per my first note above should fix it.

Otherwise then you're right, use subforms to manage the relationship.
0
 

Author Closing Comment

by:Tucker22
ID: 35024007
I added this DLookup expression, and it solved the problem:
=DLookup("[Reservation]","[LkUpTribe]","[Tribe]=Forms![Permit Actions - PSD Form].[Tribe]")

This allowed me to add the "Reservation" field from the LkUpTribe table to the form, using "Tribe" as the linking field.  Also, I am now able to add and edit records using this form; and I couldn't do this when I added the LkUpTribe table to the query on which the form is based.  

In addition to using your answer, I did need to consult my MS Access manual to get the correct syntax for the expression.

Thanks!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question