Solved

Changing the recordsource and passing parameters

Posted on 1998-05-11
2
330 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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

771 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

11 Experts available now in Live!

Get 1:1 Help Now