Add/Edit Modal Form

R

Robert Neville

I was trying to figure this out through my google group search. Yet
only found bit and pieces about various approaches.

I would like to develop a custom form to allow me to select, add, and
edit data; which in turn update a subform. This scenario presents
numerous challenges and may be somewhat ambition for my skill level.
Yet someone may lead me in the right direction with some examples or
other newsgroup threads.

My database has a company form, frmComp, with an address subform,
sfrmCompAddr. The record source for the subform is a query based on
trelCompAddr and tblAddr. Companies could have numerous addresses and
addresses could have numerous companies (many-to-many). The subform
has a combo box for the Address 1 line, cboAddr1. The aim with this
combo box involves several objectives. First, the combo box should
operate like a normal text box and allow me to edit the data. Second,
the combo box should allow me to add new data in the address table,
tblAddr. Third, the combo box should allow me to change the underlying
record source link to a previously entered address. In other words,
update the Company address to another address while leaving the
previous address intact (since other companies may use this address).

The address subform has two such combo boxes; one for Addr1 and the
other for AddrName. Unfortunately, the notinlist event does not serve
all my objectives (Edit, Add, and Select). After hours of
deliberation, I decided to build a custom dialog box, which would
allow me to edit or add data. This dialog box would activate from the
cboAddr1 on sfrmCompAddr. My approach would use the control's
listindex poperty to select case whether the user wants to edit, add,
or select. Here's where the questions begin.

With Docmd.OpenForm, you may pass OpenArgs to the opening form. But
how does one pass values back to the opening form when you close the
Add/Edit dialog form? Docmd.Close does not have any arguments for this
purpose. Do I open the form again or reactivate it somehow? I am not
sure what options I have here.

I may have to build a class module to allow more global variables to
pass through the Add/Edit dialog form and back to the calling form.
Namely, I need to test for the control that activated the Add/Edit
Dialog form since two exist; pass the AddrID identifier to Add/Edit
dialog form; pass the opening form to the Add/Edit Dialog form;
populate the Add/Edit dialog form with the address data from
sfrmCompAddr; if the Add/Edit form adds data, then it should close
the form and place a link to this new address in trelCompAddr and
populate sfrmCompAddr with the new address; if Add /Edit form edits
the data, then it should update the record in tblAddr and close the
form. Class modules are outside my realm, yet I am willing to learn
them and implemented them. Let me know if you could provide some
insight to this goal.
 

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

Top