Discussion Locked

Access 97 Question

0 helpful
13 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
I have two forms in an Access database for data entry. Each form has a record field that matches a record field in the other form. I want to be able to trigger the opening of the second form from a field on the first and go to the corresponding record. For example, if I am entering information on Company A in the first form, I want to automatically open the second form with Company A's information on that form.

13 replies

by ravi

You can put code in the "After Update" event properties for the field in question to open the second form: DoCmd.Openform "Form Name".

However, it seems to me that you need a form/subform kind of set-up, especially if there is a common field between the two forms and the data involved are in two different tables. I am afraid you haven't given enough details to comment further.

by mcse lee

I agree with answer #1 - you should try to use Form/Subform. This also allows you to update the corresponding table(s) at the same time.

by r.m.stimpson

Go to design veiw and incert a command button to open your second form and do the same on the second form to return to the frist form.

by jan d

You could make use of a new kind of form available in Access 97, the tabbed form, which makes it easy to switch from one form to another. You can put the first form on the first page, and the second on another tabbed form. The tabs can look like tabs or buttons. No programming is necessary. Alternatively, depending upon your key field linking ie linked fields (they must have the same name, be of the same data-type eg autonumber and long integer) you can do a form-subform arrangement. You can just drag and drop onto the form!

by nettech

Without knowing exactly how you have your database designed, either of the first two answers will work very well for you- IF you have your relationships defined. I think that is the only thing I would add to the top answers. If you set your relationships, and you want no programming- then used the tabbed form, make your table A a main form and table b a subform. Then you can have both forms synced, updating at the sametime.

by mbarker734

Assuming the underlying table for your second form is already populated with the company id, place the following code into your desired event (i.e. On Click, On Dbl Click etc.). The example show is how the On Double Click Event Procedure would appear for the CompanyID field, less ofcourse your naming conventions for the forms and fields. You could if you wanted apply the main body of the code to a command button.

Private Sub CompanyID_DblClick(Cancel As Integer)
On Error GoTo Err_CompanyID_DblClick

Dim DocName As String
Dim LinkCriteria As String

DocName = "frmCompanyForm2"
LinkCriteria = "[CompanyID] = Forms![frmComapnyForm1]![CompanyID]"
DoCmd.OpenForm DocName, , , LinkCriteria

Exit_CompanyID_DblClick:
Exit Sub

Err_CompanyID_DblClick:
MsgBox Error$
Resume Exit_CompanyID_DblClick

End Sub

Hope this helps.....

This discussion is closed to new replies.