Hello:
I have been struggling with building a cascading list on a form that I created. My problem is that I am getting a "Datatype Mismatch in criteria expression" error that I can not seem to figure out. I hope someone can help...
The background is that I have two drop down boxes on a form called:
cboPolicyName
cboPolicyNumber
On the rowsource for the cboPolicyName I have it pointing to my table: -
SELECT DISTINCT tblPolicyName.PolicyName, tblPolicyName.PolicyNameID FROM tblPolicyName ORDER BY tblPolicyName.PolicyName;
-
This works fine and the dropdown box populates with my various "Policy Names"
On the After update event of that same control I have the following: -
Private Sub cboPolicyName_AfterUpdate()
-
'When the Policy Name is selected, the appropriate Policy Number region list will
-
'display in the drop down list of CboPolicyNumber
-
-
On Error Resume Next
-
cboPolicyNumber.RowSource = "Select tblPolicyNumber.PolicyNumber " & _
-
"FROM tblPolicyNumber " & _
-
"WHERE tblPolicyNumber.PolicyNameID = '" & cboPolicyName.Value & "' " & _
-
"ORDER BY tblPolicyNumber.PolicyNumber;"
-
End Sub
-
I set my cboPolicyNumber control rowsource to be blank.
I am new at doing these types of cascading lists but I have looked at how they are created and I believe I did everything right. For some reason, I believe the After Update is where the error is occurring. I have looked at everything I can think of, making sure that everything is bound on column 1 and that that column is numeric.
Does anybody have any ideas what I can check or where I am going wrong???
Thanks,
Keith.
3 1961
Hello:
I saw the "how to doc." that was written by Rabbit, and followed it to a tee...The end result worked perfectly though it was different approach than I had been reading about... I am not very familiar with the "Me." values.
Here was the solution: -
-
Private Sub cboPolicyName_AfterUpdate()
-
'When the Policy Name is selected, the appropriate Policy Number list will
-
'display in the drop down list of CboPolicyNumber
-
-
With Me![cboPolicyNumber]
-
If IsNull(Me!cboPolicyName) Then
-
.RowSource = ""
-
Else
-
.RowSource = "SELECT [PolicyNumber] " & _
-
"FROM TblPolicyNumber " & _
-
"WHERE [PolicyNameID]=" & Me!cboPolicyName
-
End If
-
Call .Requery
-
End With
-
-
End Sub
-
-
The only problem I am having is that now my query I created using the Access interface wizard now comes up blank. In the criteria of that query I am pointing to the form:
[forms].[DataEntry].[cboPolicyName]
[forms].[DataEntry].[cboPolicyNumber]
If I manually input the policy name and number into the query it works.
Below is the SQL of that query: -
-
PARAMETERS [forms].[DataEntry].[cboPolyNumber] Short, [forms].[DataEntry].[cboPolyName] Short;
-
SELECT tblPolyNumber.PolicyNumber, tblPolyName.PolicyName, tblMainRes.ReIndexName, tblMainRes.Pages, tblMainRes.EffectiveDates, tblMainRes.ExpirationDate, tblMainRes.Volume, tblMainRes.Tab, tblMainRes.PolicyNumberID
-
FROM (tblPolyName INNER JOIN tblPolyNumber ON tblPolyName.PolicyNameID = tblPolyNumber.PolicyNameID) INNER JOIN tblMainRes ON tblPolyNumber.PolicyNumberID = tblMainRes.PolicyNumberID
-
WHERE (((tblPolyNumber.PolicyNumber)=[forms].[DataEntry].[cboPolyNumber]) AND ((tblPolyName.PolicyName)=[forms].[DataEntry].[cboPolyName]));
-
-
Does anybody know why it can not see the selections that have been chosen on my form?
Thanks,
Keith.
-
...WHERE (((tblPolyNumber.PolicyNumber)=[forms].[DataEntry].[cboPolyNumber]) AND ((tblPolyName.PolicyName)=[forms].[DataEntry].[cboPolyName]));
-
Does anybody know why it can not see the selections that have been chosen on my form?
Thanks,
Keith.
Hi Keith. If you are referring to two existing form fields you need to include their values in the WHERE clause as string literals (assuming both are strings): - WHERE (((tblPolyNumber.PolicyNumber) = '" & [forms].[DataEntry].[cboPolyNumber] & "') AND ((tblPolyName.PolicyName) = '" & [forms].[DataEntry].[cboPolyName] & "'"));
-Stewart
Stewart:
I was in a rush last night to get out the door but just before doing so I solved it! In the end, it was my bound column in cboPolicyName. My code (AfterUpdate) was written to look for the PolicyNameID. That is why I had a syntax error when I changed my cboPolicyName to bound on 2. To solve I dropped in my PolicyNameID into my query and put my criteria there instead of the PolicyName field. I did the later and it worked error free!
Thanks for all your help!
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Sam |
last post by:
A) Destination Table with 4 Fields.
1) Last Name
2) First Name
3) State
4) Zip Code.
B) Look up table State/Zip Code with 2 Fields
|
by: visionstate |
last post by:
Hi there,
I am building a database that requires cascading lists on a form.
I currently have (I may be adding more later) 3 combo boxes on my form
- Department, Surname and Forename.
The user chooses the department they want and then the corresponding
surnames from that department can be chosen from the Surname box and
then the Forename depending on which Surname they chose.
I then have a command button which produces the results of the...
|
by: robert |
last post by:
I am using the new beta 2 ajax control toolkit. When using the
cascading drop-down obviously the items in the lists are generated
through javascript, I would like to access these items serverside on a
postback, is this possible? At the moment when posting back the
cascading dropdown the items collection contains only one item, the
item selected.
|
by: Rabbit |
last post by:
Cascading Combo/List Boxes
This tutorial is to guide you in the creation of Cascading combo/list boxes. That is when you have multiple combo/list boxes where the selection of an option in one determines the available options in the other.
TERMINOLOGY
Row Source: The table/query from which the Combo Box or List Box gets its values. Note: There are other types of row sources that can be used but for simplicity we will stick with Tables...
|
by: klarae99 |
last post by:
Hello,
I am working on an Access 2003 Database. The tables that pertain to this issue are tblOrg, tblState, tblCity, and tblZip. I have posted the table structure with only the pertinant fields below.
tblOrg
OrgID, AutoNumber, PK
ZipID, Number, FK
tblState
StateID, AutoNumber, PK
| |
by: kcdoell |
last post by:
I have 5 cascading combo boxes on a form. Below is a sample of my vb in the first combo box:
Private Sub CboDivision_AfterUpdate()
'When the Division is selected, the appropriate Segment list will
'display in the drop down list of CboSegment
With Me!
If IsNull(Me!cboDivision) Then
|
by: LosLobo |
last post by:
Greetings all. I know that cascading lists are a common problem and in truth I my initial post here was to request help with my own, but then I figured out the right code. That being said, I have a new challenge which I'm not sure how to go about. Here is my situation:
I presently have 2 combo boxes (cboBuilding, cboRoom) and which are properly cascading. That's great, but now I want to be able to pull the RoomDescription for the room that...
|
by: Toireasa |
last post by:
Hi,
Newbie Access developer here, and my first post on this forum, so I might not get everything right - thanks in advance for your help and your patience!
I'm using Access 2007, in XP. I'm currently trying to set up a whole pile of cascading combo boxes of different levels of complexity, so I started with the easiest set - and can't even get that to work (even using the tutorial on this site at...
|
by: Outback |
last post by:
Hi. Windows XP + Access 2002.
I have three tables.
tblMakes
=======
MakeKey (PK)
Make
tblModels
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |