Solved

Data type conversion error on update query

Posted on 2009-05-16
7
677 Views
Last Modified: 2013-12-25
I have an subform in a tab control that used two combo boxes to pick values from a query.  The vales are then used in an update query to a table.

The update query runs perfectly when run from the form itself, however when I run the update query from within the form within a tab control I get "didn't update ##field(s) due to a data type conversion error".  The fields are all text and the lengths are the same.  Why would this run right from the form but give the error when the same form is embedded in a tab control?

If I ignore the error and click though it changes all the data in the AgentName field to a nul value.

I have tried sending the combo box values to text boxes and also to global variables but still get the same error when update is run from within the tab control.

- Many thanks in advance...
"UPDATE Sales_Tracking SET Sales_Tracking.AgentName = " & _

"Replace([AgentName],Forms!frm_Administration!tabctrl_Admin!cmbOldAgent, " & _

"Forms!frm_Administration!tabctrl_Admin!cmbNewAgent);"

Open in new window

0
Comment
Question by:ehorde
  • 3
  • 3
7 Comments
 
LVL 4

Expert Comment

by:paisleym
ID: 24404618
Hi

What is the query underlying those combo boxes? i.e. Both controls are returning the agents name in the first column? What if there is no new agent name selected yet (i.e. resulting in a null value)?

Marcelle
0
 
LVL 38

Expert Comment

by:Jim P.
ID: 24404928
Try changing the query to this.
"UPDATE Sales_Tracking " & _

"SET Sales_Tracking.AgentName = '" & Forms!frm_Administration!tabctrl_Admin!cmbNewAgent & "' " & _

"WHERE Sales_Tracking.AgentName = '" & Forms!frm_Administration!tabctrl_Admin!cmbOldAgent & "';"

Open in new window

0
 

Author Comment

by:ehorde
ID: 24412587
paisleym - There are two separate and very simple query that simply grab the AgentName for use as Original and the Replacement values.  

jimpen - Set instead of Replace? I will try that.

On a note, If I make the subform PopUp and Modal and call it from a command button in the tabcontrol all works without changing any of the query's code I just wanted to keep everything in the tabs instead of adding more forms that popup.
0
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.

 
LVL 38

Expert Comment

by:Jim P.
ID: 24413080
You should be able to from a button. In fact -- that is the common way of doing it.
0
 

Author Comment

by:ehorde
ID: 24436512
jimpen - I tested your suggestion and it seems to "run", although it says "About to update "0" rows" in a message box where there should be dozens of records.  I will tweek it some more.
0
 
LVL 38

Expert Comment

by:Jim P.
ID: 24436546
Can we see the surrounding code?
0
 

Accepted Solution

by:
ehorde earned 0 total points
ID: 24436986
I created a subform call "subfrm_LeadReassign_Admin" and placed that into the tabcontrol and then
placed all the controls into the subform and that fixed it.  Making the subform flat and the borders transparent makes it appear to be directly on the tab itself.

I skipped referencing the tabcontrol in the update query and referenced the subform directly.

As you can see I also added a join for some other filtering too.

I can't explain it, I am a beginner at this stuff.
UPDATE Sales_Tracking INNER JOIN Projects ON Sales_Tracking.CommunityInterestedIn = Projects.Project_Key SET Sales_Tracking.AgentName = Forms!frm_Administration!subfrm_LeadReassign_Admin!cmbNewAgent

WHERE (((Sales_Tracking.AgentName)=[Forms]![frm_Administration]![subfrm_LeadReassign_Admin]![cmbOldAgent]) AND ((Projects.ProjectName) Like [Forms]![frm_Administration]![subfrm_LeadReassign_Admin]![cmbProjectFilter] & "*"));

Open in new window

0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
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.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

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

12 Experts available now in Live!

Get 1:1 Help Now