Solved

Data type conversion error on update query

Posted on 2009-05-16
7
678 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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
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 …

930 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

14 Experts available now in Live!

Get 1:1 Help Now