Solved

Problem passing an integer to a Filter in Access 2010 VBA

Posted on 2013-06-29
2
900 Views
Last Modified: 2013-06-29
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
Comment
Question by:martmac
2 Comments
 
LVL 77

Accepted Solution

by:
peter57r earned 500 total points
ID: 39286544
If the field ActionTypeID is a number field then you do not want the ' '.

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

Author Closing Comment

by:martmac
ID: 39286627
Bingo, thanks so much, that's done the trick.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now