Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 8th, 2006, 12:04 AM
Registered User
 
Join Date: Sep 2006
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default Passing two PK's to the next form

I am trying to link my customerID and my TroubleTicketID to my work order.

I have a subform under the customer form that shows all of the trouble Tickets for that particular customer. I want to create a button that will open a new work order and populate the customerID and the trouble ticketID so that the association will work properly.

I am using the following code.

Private Sub Command10_Click()
On Error GoTo Err_Command10_Click

Dim stDocName As String
Dim stLinkCriteria As String
DoCmd.RunCommand acCmdSaveRecord
stDocName = "WorkOrder"

stLinkCriteria = _
"([TroubleTicketID]=" & Me![TroubleTicketID] & _
") And ([CustomerId]=" & Me![CustomerID] & _
") AND [workorderId]= -1"


DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command10_Click:
Exit Sub

Err_Command10_Click:
MsgBox Err.Description
Resume Exit_Command10_Click

End Sub

Any help would be appreciated.
MrFormula
 
Old September 8th, 2006, 06:49 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

This will not work because it is looking for existing records, not populating fields.

In the form's On Open event, I think, take values from the parent form that is already open:

(Me.) = the new form...

Me.CustomerID = [Forms]![frmParentForm].[CustomerID]
Me.TroubleTicketID = [Forms]![frmParentForm].[TroubleTicketID]

If the form is set to open on a new record, this should auto populate the fields.

Did this help?



mmcdonal





Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing variables from 1 form to another. jainin_shah9 C# 10 February 18th, 2008 07:59 PM
passing unique record from form to form Baconant Beginning VB 6 1 January 2nd, 2008 06:20 PM
Passing FORM to FORM to PHP AV1611 PHP Databases 1 August 17th, 2005 03:32 PM
Passing variale from 1 form to another. johnsonlim026 ASP.NET 1.0 and 1.1 Basics 9 August 17th, 2005 12:53 AM
Passing Value from main form to Popup Form smartgir Access VBA 0 February 26th, 2004 06:26 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.