Autofill In Linked Forms

  • Thread starter Faraz A. Qureshi
  • Start date

Faraz A. Qureshi

I have created a couple of forms by selecting all the fileds in the form
wizard from two tables:

1. Suppliers (Fields: Supplier, Address, Contact, etc.)
2. Products (Fields: Supplier <Lookedup from Supplier Table>, Product, Rate,

Upon clicking the toggle button on Suppliers form I have the Products form
opened. However, as I enter the data in it, I want the Supplier filed in the
same be automatically be filled with the Supplier name as in the opened
Supplier form so as to be filtered and displayed the next time I open the
same instead of manually inserting the same with each entry.

Any idea?

Tom van Stiphout

On Wed, 3 Feb 2010 12:26:01 -0800, Faraz A. Qureshi

Toggle button?
That aside, what I would do is pass the current Supplier into the
Product form, then use that information to set the default value.

As another note: I am assuming you're using standard best practices so
you have a numeric SupplierID in the Supplier table, and it's the
Primary Key.
A supplier dropdown typically is bound to a query returning the
SupplierID and SupplierName. The ID column is made invisible by
setting the ColumnWidths property to "0;1".

In your button-click event you open the form:
docmd.OpenForm "frmProducts", OpenArgs:="SupplierID=" & Me.SupplierID.

In the Products form we can use this info:
In the Form_BeforeInsert event:
dim strOpenArgs() as string
strOpenArgs = split(Me.OpenArgs, "=")
Me.SupplierID = strOpenArgs(1)

That should do it. You may need to rename some object names that I

Microsoft Access MVP

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question