• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1056
  • Last Modified:

Problem passing an integer to a Filter in Access 2010 VBA

I am having a problem applying a filter of a form using a dropdown with the following code

Private Sub ActionFilter_AfterUpdate()
Dim intActionTypeID As Integer


intActionTypeID = Me.ActionFilter.Column(0)

MsgBox strActionTypeID  '(just put this here to check integer is correct)


Me.Filter = "[ActionTypeID] = '" & strActionTypeID & "'"

Me.FilterOn = True
End Sub

Open in new window


It appears the value (1) is being passed, but I get the message "The search key was not found in any record", so I am assuming the problem is in ... '" & strActionTypeID & "'", but I can't work out what it is. If I use Me.Filter = "[ActionTypeID] = 1" then it works.

Can anyone help before I jump out the Window?
0
martmac
Asked:
martmac
1 Solution
 
peter57rCommented:
If the field ActionTypeID is a number field then you do not want the ' '.

Me.Filter = "[ActionTypeID] = " & strActionTypeID
0
 
martmacAuthor Commented:
Bingo, thanks so much, that's done the trick.
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now