?
Solved

Access 2007 Open a datasheet subform in either acFormAdd or acFormEdit depending

Posted on 2011-10-28
4
Medium Priority
?
580 Views
Last Modified: 2012-05-12
Hi,
I have a PO detail subform in a one-to-one relationship with a PO table.  They are both displayed as form datasheet -- the detail is revealed by clicking on the '+'.  

If the primary key of the PO already exists in the detail table I need the detail subdatasheet to open in edit mode; if the primary key of the PO doesn't exist in the detail table, I need the subdatasheet to open in addition mode (able to add a new record).  

I don't know how to check the detail table for the PO key of the parent; I can open the form in acFormAdd but not in the subdatasheet, etc.  Guidance please dear gurus.
0
Comment
Question by:Prisoner362670
  • 2
  • 2
4 Comments
 
LVL 85
ID: 37048099
You have no control over how the native (and Access controlled) SubDatasheet presents itself. You can mimic much of the bevhavior of the datasheet + subdatasheet by building two forms (both in datasheet view) and embedding the child datasheet form in the parent datasheet form and perhaps control that functionality in the Load or Open event of the subdatasheet, but that's probably about as far as you could get.

0
 

Accepted Solution

by:
Prisoner362670 earned 0 total points
ID: 37128475
There were actually two solutions both fairly simple:
1) Base the datasheet form and its subdatasheet on the same table just use a different query to pase up the data presentation for the user; or
2) whenever a new record is created in the table used as a datasource for the datasheet form, also create a new record in the detail table on which the subdata sheet is based.  All subdatasheets display in edit only mode and are in a one-to-one relationship with the datasheet form table.

I do not award myself points; nor do I award them to LSMC Consulting.
0
 

Author Closing Comment

by:Prisoner362670
ID: 37158251
I used a sql insert into...values statement.
0
 
LVL 85
ID: 37130612
Good suggestion on using Queries for your forms.

However, adding a new record to a child table whenever a parent record is created can cause troubles when querying and reporting, so be careful with that. In most cases, it's not a good idea to "auto add" blank records.
0

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

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

Microsoft's Excel has many features that most people will never need nor take advantage of.  Conditional formatting is one feature that you may find a necessity once you start using it.
Quickbooks hosting can do wonders to your enterprise but considering the points elaborated in the article which will help you to better analyze the outcomes. So scan your business, its needs and then move to the new world of limitless benefits.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…

839 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