Solved

Data type conversion error on update query

Posted on 2009-05-16
7
680 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
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
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 …

828 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