Runtime error 2001

G

G13m

I have a form that has an unbound combo for filtering to a record in the
source table of the form. This is the code for the combo:

Private Sub cmbProductId_AfterUpdate()

If IsNull(Me.cmbProductId) Then ' Turn filter off
Me.Filter = vbNullString
Me.FilterOn = False
Else
Me.Filter = "[REPAIREVENTID] = '" & Me.cmbProductId & "'" ' Filter
for the selected Product
Me.FilterOn = True
End If

End Sub

The combo has a few columns but REPAIREVENTID is the bound column in the
combo dropdown.

When I select an item from the dropdown, I get Runtime error 2001 on the
'filter for [REPAIREVENTID]' line of code. Funny thing is I did a very
similar thing in another form and it works fine. RMA is a field in the source
table of the form:


Private Sub cmbRMA_AfterUpdate()

If IsNull(Me.cmbRMA) Then
' Turn filter off
Me.Filter = vbNullString
Me.FilterOn = False
Else
Me.Filter = "[RMA] = '" & Me.cmbRMA & "'" '
Filter for the selected RMA
Me.FilterOn = True
End If



Me!fsubEditRepairDetail.Enabled = True ' Enable the form for data
entry
Me.cmbCustomer.Enabled = True
Me.cmbCUSTPO.Enabled = True
Me.txtPODATE.Enabled = True
Me.tglShowCalendar.Enabled = True
Me.cmdDeleteRMA.Enabled = True

End Sub



The forms' and the combos' properties appear to be identical and I'm stumped.

Thanks for any help.
 
M

Maurice

Is the productID field a string value or a numerical value? If it's a
numerical value lose the "'" after the me.cmbProductID and before the
[repaireventID] so it should look like this:

Me.Filter = "[REPAIREVENTID] = " & Me.cmbProductId

if it's a string try setting the initial stringvalue to "" instead of
vbNullString.

hth
 
G

G13m

Works perfectly now. Thanks!

Maurice said:
Is the productID field a string value or a numerical value? If it's a
numerical value lose the "'" after the me.cmbProductID and before the
[repaireventID] so it should look like this:

Me.Filter = "[REPAIREVENTID] = " & Me.cmbProductId

if it's a string try setting the initial stringvalue to "" instead of
vbNullString.

hth
--
Maurice Ausum


G13m said:
I have a form that has an unbound combo for filtering to a record in the
source table of the form. This is the code for the combo:

Private Sub cmbProductId_AfterUpdate()

If IsNull(Me.cmbProductId) Then ' Turn filter off
Me.Filter = vbNullString
Me.FilterOn = False
Else
Me.Filter = "[REPAIREVENTID] = '" & Me.cmbProductId & "'" ' Filter
for the selected Product
Me.FilterOn = True
End If

End Sub

The combo has a few columns but REPAIREVENTID is the bound column in the
combo dropdown.

When I select an item from the dropdown, I get Runtime error 2001 on the
'filter for [REPAIREVENTID]' line of code. Funny thing is I did a very
similar thing in another form and it works fine. RMA is a field in the source
table of the form:


Private Sub cmbRMA_AfterUpdate()

If IsNull(Me.cmbRMA) Then
' Turn filter off
Me.Filter = vbNullString
Me.FilterOn = False
Else
Me.Filter = "[RMA] = '" & Me.cmbRMA & "'" '
Filter for the selected RMA
Me.FilterOn = True
End If



Me!fsubEditRepairDetail.Enabled = True ' Enable the form for data
entry
Me.cmbCustomer.Enabled = True
Me.cmbCUSTPO.Enabled = True
Me.txtPODATE.Enabled = True
Me.tglShowCalendar.Enabled = True
Me.cmdDeleteRMA.Enabled = True

End Sub



The forms' and the combos' properties appear to be identical and I'm stumped.

Thanks for any help.
 

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