Solved

Changing the recordsource and passing parameters

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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
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…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

920 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

16 Experts available now in Live!

Get 1:1 Help Now