OpenForm WhereCondition Problem

Prysson

Registered User.
Local time
Today, 17:42
Joined
Sep 23, 2002
Messages
45
I have a form that has as its source a tblTrainingSystems

The form name is frmTrainingSystems

On the form is a listbox "ListTrainingSource"

and a button "cmdEditTrainingSystem

the form has an efter update event that selects records in the tblTrainingSystems dependant on what record is selected in the ListTrainingSource list box.

When you click on the button (cmdEditTrainingSystem)

the on click shoudl open a seperate for named frmEditTrainPopUp

This form is supposed to have a field that is synchronized with the selected option in the ListTrainingSource list box.

It was suggested to me that a WhereCondition in the OpenForm line would create this link...

A couple of questions...is the field on the pop-up form supposed to be a txt box...that is my assumption anyway.

Also supposing that it is what is wrong with the following code that is attempting to link the forms....


Private Sub cmdEditTrainingSystem_Click()
On Error GoTo Err_cmdEditTrainingSystem_Click

Dim stDocName As String
Dim stLinkCriteria As String
stWhere = "txtEditTrainingSystem = Forms![frmEditTrainingSystem]![ListTrainingSource]"
stDocName = "frmEditTrainPopUp"
DoCmd.OpenForm stDocName, WhereCondition:=stWhere

Exit_cmdEditTrainingSystem_Click:
Exit Sub

Err_edittest2_Click:
MsgBox Err.Description
Resume Exit_edittest2_Click

End Sub
 
Try This:

Code:
Private Sub cmdEditTrainingSystem_Click() 
On Error GoTo Err_cmdEditTrainingSystem_Click 

Dim stDocName As String 
Dim stLinkCriteria As String 
   stWhere = "[Forms underlying Table Field Name] =" & Forms![frmEditTrainingSystem]![ListTrainingSource]

   stDocName = "frmEditTrainPopUp"   
   DoCmd.OpenForm stDocName, WhereCondition:=stWhere 

Exit_cmdEditTrainingSystem_Click: 
Exit Sub 

Err_edittest2_Click: 
MsgBox Err.Description 
Resume Exit_edittest2_Click 

End Sub
 

Users who are viewing this thread

Back
Top Bottom