Combo Box in a Split Form

JoeyB_99

Registered User.
Local time
Today, 15:46
Joined
Jul 6, 2012
Messages
78
I am using Access 2007 and have created a split form.

Using the wizard I then added a combo box for the user to select records based on a field called Formatted Cost Code. The wizard left a macro in the After Update property of the control for the combo box. I converted this to VBA using the Access 'conversion wizard', resulting in the following code,


Private Sub cmbBxFormattedCostCode_AfterUpdate()
On Error GoTo Combo39_AfterUpdate_Err

DoCmd.SearchForRecord , "", acFirst, "[RecordID] = " & Str(Nz(Screen.ActiveControl, 0))

Combo39_AfterUpdate_Exit:
Exit Sub

Combo39_AfterUpdate_Err:
MsgBox Error$
Resume Combo39_AfterUpdate_Exit

End Sub


But I want the user to be able to filter out all records that don't match the "cost code" selection. So I searched 'Net and found a posting called "Filtering split form records from combo box", and found a response by Bob Larson on 10/02/2009. He suggested the following code be inserted into the After Update property of the control for the combo box,



Me.Filter = "[Formatted Cost Code]='" & [cmbBxFormattedCostCode] & "'"

Me.FilterOn = True



I have inserted this code but I am not getting the desired effect. When I make a selection using the combo box I see the records I want in the datasheet view but I also see all other records.

What am I doing wrong?
 
In order to answer this, I need to know:
1) The structure of underlying table of the form or, if the form is based on a query, the query's SQL.
2) The SQL for the combo row source
2.1) The number of bound column of the combo

BTW: Do not use spaces in names !!!!
Formatted Cost Code should be FormattedCostCode
 

Users who are viewing this thread

Back
Top Bottom