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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Syntax from subform to another form

Status
Not open for further replies.

nycbigapple

Technical User
Apr 4, 2006
33
0
0
US
Hi, I have an unbound form that has a continuous subform.
When I select a record from the subform, I want it to open the form for that selected record.

Code:
stDocName = "frmEmployeeRecordsIndividual"
stLinkCriteria = "[EmployeeID]=" & Forms![frmEmployeeRecords]![sfrmEmployeelist].Form![EmployeeID]

I have tried various of combinations and stuck on this thank you.
 
And where is your DoCmd.OpenForm call ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
I get errors 'ms office can not find the field 'sfrmEmployeeList' referred in your expression.

When I change the code with "Forms![frmEmployeeRecords]![sfrmEmployeelist].Form![EmployeeID]"

I get a parameter

Code:
On Error GoTo Err_Command13_Click

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "frmEmployeeRecordsIndividual"
    
    stLinkCriteria = "[EmployeeID]=" & Forms![frmEmployeeRecords]![sfrmEmployeelist].Form![EmployeeID]

    DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command13_Click:
    Exit Sub

Err_Command13_Click:
    MsgBox Err.Description
    Resume Exit_Command13_Click
 
Have a look here:

Seems that the control hosting your subform has a different name than sfrmEmployeelist ...

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
I made certain the unbound form is frmEmployeeRecords
the subform is sfrmEmployeeList and the field is called EmployeeID

The form that I am trying to opne is frmEmployeeRecordsIndividual
 
Play with the expression builder (Forms -> Loaded forms) to discover the syntax to use.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
If you are using the command button in subform to open other form, you don't need to make the complete path.

try with this criteria:

stLinkCriteria = "[EmployeeID]=" & Me.sfrmEmployeelist.Value


Fekri
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top