Solved

Changing the recordsource and passing parameters

Posted on 1998-05-11
2
346 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Send Meeting Request from Shared Mailbox 3 59
send attachment with email in an ms access form 1 40
ADODB problem 20 38
MS-Access not responding 5 20
The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

837 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