Solved

An expression you entered is the wrong data type for one of the arguments

Posted on 2006-07-17
4
943 Views
Last Modified: 2010-08-05
I have created a form called frmContactCategoryFilter which lists ContactCategory in an unbound box
When the user selects a ContactCategory and clicks OK, frmContact is opened showing only records which have the same ContactCategoryID as the selection
The 'OK' button has the following code

    Dim DocName As String
    Dim LinkCriteria As String

    DocName = "frmContact"
    LinkCriteria = "[ContactCategoryID] = Forms![frmContactCategoryFilter]![lstContactCategory]"
    DoCmd.OpenForm DocName, , , LinkCriteria
           
And it works.
When frmContact opens, I would like frmContactCategoryFilter to close.

However, whenever I try to add a DoCmd.Close , frmContact opens showing the correct records,
the message "An expression you entered is the wrong data type for one of the arguments" is displayed
and frmContactCategoryFilter remains open.

What should I do?
0
Comment
Question by:Ludique
  • 2
4 Comments
 
LVL 34

Assisted Solution

by:flavo
flavo earned 250 total points
ID: 17127815
I can't see how it works in either case, this line:

    LinkCriteria = "[ContactCategoryID] = Forms![frmContactCategoryFilter]![lstContactCategory]"

Should read:

    LinkCriteria = "[ContactCategoryID] = " &  Forms![frmContactCategoryFilter]![lstContactCategory]

Dave
0
 
LVL 35

Accepted Solution

by:
Raynard7 earned 250 total points
ID: 17127831
Try

docmd.Close acForm, Me
0
 

Author Comment

by:Ludique
ID: 17127840
I changed the line as shown
added     DoCmd.Close acForm, "frmContactCategoryFilter"
And it works.

Thanks Dave.

Steph.
0
 
LVL 34

Expert Comment

by:flavo
ID: 17128028
Not a problem, glad to help!

Dave
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Suggested Solutions

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…
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
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…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

830 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