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!

Automatically sort based on ChangeOrder Field 2

Status
Not open for further replies.

netrusher

Technical User
Feb 13, 2005
952
US
I have the below code on a command button that will sort
records based on a number in the ChangeOrder field on
the form. This works good. I can change the number in the
ChangeOrder field and sort the records the way I need.

These records are PartNumbers and are always associated
with a ECN Number. My issue is when I go back to this ECN
Number and I view the PartNumbers on the subform I need
for them to automatically sort based on the Numbers in the
ChangeOrder field. Rignt now they always go back to the
original order. How can I do this? Do I need to put
this same code on another Event to accomplish this?

Code:
Me.OrderBy = "ChangeOrder " & SortDir
Me.OrderByOn = True
 
Remou,

I did but this is a continuous form and when I put the code
there it would not let me go to each ChangeOrder field to
change numbers. It kept jumping to the top record in the
ChangeOrder Field.

I think it would be best to sort this form from the
afterUpdate Event of the ECNNumber field of the form where
the ECN number is selected but I get a:
Compile error: Variable not defined and the code
blows up on the SortDir of the code.

The ECN Number is on Form ECNBCNVIPfrm and the part
numbers I want to sort are on the ECNPartsfrm2 Form.
This form ECNPartsfrm2 is on another page of the
ECNBCNVIPfrm which I think makes it a subform.

I think the Idea time to run the code would be when I select
what ECN I want. Any advice on how to make the code work
from the AfterUpdate event of the MainForm ECNBCNVIPfrm
 
To run the code from another form, use the full form reference instead of Me:

Forms![FormName].[SubformControlName].Form.OrderBy=...
 
Remou,

Below is the code I put on the main form and I am getting
the same error as above and the code seems to be blowing
up on the SortDir

Code:
Forms![ECNBCNVIPfrm].[ECNPartsfrm2].Form.OrderBy = "ChangeOrder " & SortDir
Me.OrderBy = True
 
Where is SortDir?

You will need to change:

Me.OrderBy = True

In a similar way.

 
Remou,

I do not even know what SortDir is? I got this code from
another source. What I am doing is sorting PartNumbers based
on numbers in the ChangeOrder field of my form.
 
I am a little confused. What happens if you leave out SortDir?

Forms![ECNBCNVIPfrm].[ECNPartsfrm2].Form.OrderBy = "ChangeOrder"

<...>
 
Below is the code I tried and I get the following Error:
Run-time error 2465
BEREA/ECN/BCN/VIP Databse can't find the field '|' referred
to in your expresion
Code:
Forms![ECNBCNVIPfrm].[ECNPartsfrm2].Form.OrderBy = "ChangeOrder"
Forms![ECNBCNVIPfrm].[ECNPartsfrm2].Form.OrderBy = True
 
actually the code below is what I tried

Code:
Forms![ECNBCNVIPfrm]![ECNPartsfrm2].Form.OrderBy = "ChangeOrder"
Forms![ECNBCNVIPfrm]![ECNPartsfrm2].Form.OrderBy = True
 
Do you have a field ChangeOrder on a form called ECNBCNVIPfrm with a subform control called ECNPartsfrm2?

In the case above, it may be best to use dot (.) rather than (!), because the error will show up when you compile.
 
The ChangeOrder field is on the ECNPartsfrm2 Subform.

I have OrderBy on the ChangeOrder Field of this subform.
I would like to just requery the ChangeOrder field but I
do not know how to do that from the [ECN Number] field
on the ECNBCNVIPfrm AfterUpdate Event.
 
Replace this:
Forms![ECNBCNVIPfrm]![ECNPartsfrm2].Form.OrderBy = True
with this:
Forms![ECNBCNVIPfrm]![ECNPartsfrm2].Form.OrderByON = True

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
PH

Below is the code I used.
Code:
Forms![ECNBCNVIPfrm]![ECNPartsfrm2].Form.OrderBy = "ChangeOrder" & SortDir
Forms![ECNBCNVIPfrm]![ECNPartsfrm2].Form.OrderByOn = True
I got the following error.
The expression
After Update you entered as the event property setting
producted the following error: Variable not defined.
 
I have no idea. I got this code from someone else and it
works as long as I am on the Subform. I really would just
like to requery the [ChangeOrder] field on the Sub form
from the mainform
 
what about this ?
Forms![ECNBCNVIPfrm]![ECNPartsfrm2].Form.OrderBy = "ChangeOrder"
Forms![ECNBCNVIPfrm]![ECNPartsfrm2].Form.OrderByOn = True

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
PHV,

I am getting the following error:
Run-time error '2465':
Berea ECN/BCN/VIP Database can't find the field 'ECNPartsfrm2
referred to in your expression.

ECNPartsfrm2 is not a field but a form! I do not understand
the error.
Code:
Forms![ECNBCNVIPfrm]![ECNPartsfrm2].Form.OrderBy = "ChangeOrder"
Forms![ECNBCNVIPfrm]![ECNPartsfrm2].Form.OrderByOn = True
 
Use the name of the subform control.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Do you mean replace [ECNPartsfrm2] with [ChangeOrder]?

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top