Code Question

D

DS

I'm using this code to sync a subform to a subform. It works fine, bu
it doesn't give me just the records for the current item. It gives me
all of the recordsfor that item. How would you put a CloneRecordset or
Bookmark in here so that it only returns the current records?

The fields are....

Main Form
ORDERS Order ID

1st Subform
Orders ID
Product ID

2nd Subform
Product ID, Mod ID

Sub Form_Current()
Dim strParentDocName As String

On Error Resume Next
strParentDocName = Me.Parent.Name

If Err <> 0 Then
GoTo Form_Current_Exit
Else
On Error GoTo Form_Current_Err
Me.Parent![Mods Detail].Requery
End If

Form_Current_Exit:
Exit Sub

Form_Current_Err:
MsgBox Err.Description
Resume Form_Current_Exit

End Sub

Thanks for any Help
DS
 
T

Troy

Why use code when you don't need to?

1. On your 1st Subform, rename the control containing the Product ID to
something different than the control source. For instance, if the Control
Source and name of the control are both "ProductID", rename the control to
"cboProductID" and leave the control source as it is.

2. On the second Subform reference the 1st subform in the Link Master fields
property box.

NOTES:
a. You must use the name of the subform control on the parent and NOT the
name of the form it contains. Access names subform controls something like
"Childxxx" by default. So, the name of the control on the parent and not the
name of the subform it contains.

b. You need to reference the control name itself and not the name of the
recordsource. That's why Step 1 is in here!

Your end result in the properties for Sub Form 2 control should look similar
to the following:

Link Child Fields = ProductID
Link Master Fields = [Child1].[Form].[cboProductID]

--
Troy

Troy Munford
Development Operations Manager
FMS, Inc.
www.fmsinc.com


I'm using this code to sync a subform to a subform. It works fine, bu
it doesn't give me just the records for the current item. It gives me
all of the recordsfor that item. How would you put a CloneRecordset or
Bookmark in here so that it only returns the current records?

The fields are....

Main Form
ORDERS Order ID

1st Subform
Orders ID
Product ID

2nd Subform
Product ID, Mod ID

Sub Form_Current()
Dim strParentDocName As String

On Error Resume Next
strParentDocName = Me.Parent.Name

If Err <> 0 Then
GoTo Form_Current_Exit
Else
On Error GoTo Form_Current_Err
Me.Parent![Mods Detail].Requery
End If

Form_Current_Exit:
Exit Sub

Form_Current_Err:
MsgBox Err.Description
Resume Form_Current_Exit

End Sub

Thanks for any Help
DS
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top