Solved

Unable to add or edit records using form

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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Familiarize people with the process of utilizing SQL Server stored procedures 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 Micr…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

791 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