Simple-Moderate Question: Why isn't this Form_Open VBA Code working

Bill Bisco

Active Member
Joined
Aug 8, 2007
Messages
446
I have a form and a subform. I'm trying to use the Form_Open Command to affect the Subform. Here is my code:

Code:
Private Sub Form_Open(Cancel As Integer)

'Me!frmProcessSelectLSSubform.Form!OrderBy = "ProcessSEQ"
'Me!frmProcessSelectLSSubform.Form!OrderByOn = True

'Forms!frmProcessSelectLSRS!frmProcessSelectLSSubform.Form.OrderBy = "ProcessSEQ"
'Forms!frmProcessSelectLSRS!frmProcessSelectLSSubform.Form.OrderByOn = True

Me!frmProcessSelectLSSubform.OrderBy = "ProcessSEQ"
Me!frmProcessSelectLSSubform.Form.OrderByOn = True

'Me!frmProcessSelectLSSubform.Form!OrderBy = "ProcessSEQ"
'Me!frmProcessSelectLSSubform.Form!OrderByOn = True

End Sub
For some reason. It thinks that I'm trying to refer to a field when I'm trying to Orderby. Any help is appreciated.

Sincerely,
Bill
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
1. is this code on the main form or subform?

2. You use a period between .Form and the OrderBy (.Form.OrderBy) and not the bang (!).
 
Upvote 0
1. Yeup, I'm on the Main form trying to affect the Subform.

2. Yes, I used a period and not a !, as you can see in my uncommented part. I'm still having trouble though and I don't know why :confused:
 
Upvote 0
One more question - Are you sure you are referencing the name of the subform CONTAINER (the control on the main form that houses the subform) and not the subform (unless they are the same exact name then it is okay).
 
Upvote 0

Forum statistics

Threads
1,214,632
Messages
6,120,649
Members
448,975
Latest member
sweeberry

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top