Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Unable to add or edit records using form

Posted on 2011-03-02
3
Medium Priority
?
395 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 14

Accepted Solution

by:
pteranodon72 earned 2000 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

670 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