Solved

Problem passing an integer to a Filter in Access 2010 VBA

Posted on 2013-06-29
2
887 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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…

747 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

8 Experts available now in Live!

Get 1:1 Help Now