Solved

Data type conversion error on update query

Posted on 2009-05-16
7
682 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 
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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

752 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