Solved

Unable to add or edit records using form

Posted on 2011-03-02
3
384 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now