Solved

Changing the recordsource and passing parameters

Posted on 1998-05-11
2
340 Views
Last Modified: 2008-02-26
I have a form that has it's recordsource set to a query which includes the data from two tables.  The first table is a master table and the second is a detail table.  I am using an unbound form to ask the user which master record they want.  The form has the name & address information from the master table plus a subform for the detail records.  The navigation keys (custom) are in the subform.  All works well for editing and deleting but... when I need to add a detail record I run into trouble.  I know what mode I'm in because I pass openargs to the form.  How can I locate the master record that they want, pass key information to the form and go into add mode?   What about the link fields in the subform?  Can anyone help me?  Does anyone have any samples that do this?  I'm am very frustrated....HELP!
0
Comment
Question by:Accessed
2 Comments
 
LVL 2

Accepted Solution

by:
Bangerter earned 50 total points
ID: 1967027
create a button on the main form called search. put an unbound text control box next to the button. in the button's 'OnClick' event go to the code builder and put this.

forms![MyMainForm].recordsource = "SELECT DISTINCTROW ....

copy the sql statement of your main form here then at the end of it put in the where clause

where (form![MyMainform]![MyKeyedField] = [MyUnboundField])

here is an example of what the statement it might look like in the buttons 'OnClick' event:

forms![MyMainForm].recordsource = select distincrow COLLECT.InputDate, COLLECT.Lease, COLLECT.Lessee, COLLECT.ILAccount, COLLECT.LesseeID, COLLECT.Address, COLLECT.ILNote, COLLECT.ChgOffAmt, COLLECT.Gross, COLLECT.AucSold
FROM COLLECT
WHERE (COLLECT.Lease=[forms]![fpremaint]![field0])
order by collect.inputdate desc;

i would also put a button titled 'Clear' next to your search button and in its 'OnClick' event put the same thing in the code except leave the 'where' statement out at the end.

you should now be able to search for any record you want and when it comes up you can then click in the subform and add a new record.

understand too that you cant add a record to the subform for a client that does not yet exist in the main form.

let me know if this is not what you wanted and i can you help you further with more detail as to what you want
0
 

Author Comment

by:Accessed
ID: 1967028
Bangerter,

Thank-you for your response - it got me thinking.  My problem - believe it or not - was that I was opening up the form with ACFORMADD.  Duhhhhh
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
type of query 11 41
Delete QueryDef IF it Exists: Access VBA 5 32
Allow user to edit an outgoing email 2 24
DCount Type Mismatch 2 21
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…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

786 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