Combo Box (VBA Code) in Split Form

Martano0811

Registered User.
Local time
Today, 11:10
Joined
May 14, 2012
Messages
16
I created a Combo Box (in the form header) for Region (Central, East, West). I dropped the the Data table into the Detail section of the form. (Contains feild called Region)

I would like to be able to drop down say on the Central Region and see all rows for Cental...in this example it it 250 rows out of the 951. However, at this point its only allowing me to see the next record in Central not all records. How would I keep only in a certain Region by using the Combo Box?


Here is VBA code that I beleive needs to be put in place to isolate only rows that are int he Central Region.


Example:
Private Sub MyComboBoxName_AfterUpdate()
On Error GoTo Err_ErrorHandler
Dim ItemSelected As String
ItemSelected = Forms!MyFormName.MyComboBoxName
MyComboBoxName = Null
Me.Filter = "MySearchField = '" & ItemSelected & "'"
Me.FilterOn = True
Err_ErrorHandler:
Exit Sub
End Sub

My Example:

Option Compare Database
Private Sub cmbRegion_AfterUpdateUpdate(Cancel As Integer)
On Error GoTo Err_ErrorHandler
Dim ItemSelected As String
ItemSelected = Forms!CPCForm2.cmbRegion
cmbRegion = Null
Me.Filter = "Region= '" & ItemSelected & "'"
Me.FilterOn = True
Err_ErrorHandler:
Exit Sub
End Sub
Private Sub cmbRegion_BeforeUpdate(Cancel As Integer)
End Sub
 
Send a short example of your MDB, (access2000 or 2002-2003).
 
looks same to my issue
 
If you want to use automation I strongly urge you to avoid Split Forms entirely and build the same structure using subforms.

Split forms have an incomplete object model which prevents several aspects being manipulated with VBA.
 

Users who are viewing this thread

Back
Top Bottom