Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 996
  • Last Modified:

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

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
Ludique
Asked:
Ludique
  • 2
2 Solutions
 
flavoCommented:
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
 
Raynard7Commented:
Try

docmd.Close acForm, Me
0
 
LudiqueAuthor Commented:
I changed the line as shown
added     DoCmd.Close acForm, "frmContactCategoryFilter"
And it works.

Thanks Dave.

Steph.
0
 
flavoCommented:
Not a problem, glad to help!

Dave
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

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