Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open Another from Current

Status
Not open for further replies.

jbento

Technical User
Jul 20, 2001
573
US
All,
I would like to Open another form from a current form, based on a ID field. The two forms I have are connected to two different tables. Would I have to create a query with those two tables, and relate the ID fields, and assign the query to both forms? Would there be code for the form that has the command button like this, after I relate:

Private Sub Form_Click()

Dim stLinkCriteria As String

DoCmd.ApplyFilter , Me![ID] = Forms![frmTwo]![ID]

Is this the correct approach? Please help.

Jerome
 
Dear Jerome:

U'er rite abt the link criteria approach but ur code is combining two different methods i.e lunk criteria and filtering. The way ur code is written now will not function. Here is the code for LINK CRITERIA

On Error GoTo Err_CmdCancerDetails_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "FrmUterusCancer"

stLinkCriteria = "[PriDiagID]=" & Forms![FrmPatients]![FrmPrimaryDiagnosis]![PriDiagID]

DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_CmdCancerDetails_Click:
Exit Sub

Err_CmdCancerDetails_Click:
MsgBox Err.Description
Resume Exit_CmdCancerDetails_Click

Please note that [FrmPrimaryDiagnosis] is the name of 1st form and from that form I am opening [FrmUterusCancer] by using the link field of [PridiagID]. You must have some relational field between two tables.

You should also set the default value of the linked field on the 2nd form as
=[Forms]![FrmPatients]![FrmPrimaryDiagnosis]![PriDiagID]

so that when u are entering a new record from ur 1st form to 2nd form, the PriDiagID u've entered in the 1st form will automaticaly be assigned to the PriDiagID on the 2nd form when it is opened in New Record mode.

Hope that solves ur problem

Cheers!
Aqif

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top