Solved

Unable to add or edit records using form

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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Suggested Solutions

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

914 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

21 Experts available now in Live!

Get 1:1 Help Now