Solved

String chain and SQL

Posted on 2004-08-31
11
278 Views
Last Modified: 2012-06-21
In a group of records I have two fields
"Productor" and "Field" defined as STRING
As the user enter it, data is as such

Productor    Lote
-------------------
PPK            5452
PPK            2012
PPK            8523

I need a group button in the form (data is displayed in continuous form) to change for each record :

PPK is deleted and the third digit of the Lote is put in Productor. The fourth and first digit are now first and second and the second digit is the third so data will become :

Productor      Lote
--------------------

5                  254
1                  220
2                  385

I will like it to be SQL statement, so I can put the boton on any form.

Thamk you                    



0
Comment
Question by:maguerez
  • 4
  • 3
  • 2
11 Comments
 
LVL 26

Expert Comment

by:dannywareham
ID: 11942603
What do you want it to update?
Do you want it to change the table value? Just show the value on the form?
0
 
LVL 44

Expert Comment

by:GRayL
ID: 11942735
Update table (Productor, Lote) select mid(Lote,3,1), Right(Lote,1) & Left(Lote,2) From table;
0
 

Author Comment

by:maguerez
ID: 11942873
I want to change the data in the table
0
 
LVL 26

Expert Comment

by:dannywareham
ID: 11942882
GRayL has teh answer for you then

An UPDATE query.   :-)
0
Backup Your Microsoft Windows Server®

Backup 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.

 

Author Comment

by:maguerez
ID: 11943209
I have a syntax error :
DoCmd.RunSQL "UPDATE CCCit (Productor,NºLote) SELECT mid(NºLote,3,1), Right(NºLote,1) & Left(NºLote,2) From CCCit Where [nopartida]=[formularios].[Controlcalidadmaster].[nopartida]"

argghh !
0
 

Author Comment

by:maguerez
ID: 11943914
Can anybody help on the syntax problem ?
0
 
LVL 44

Expert Comment

by:GRayL
ID: 11944016
DoCmd.RunSQL "UPDATE CCCit (Productor,NºLote) SELECT mid(NºLote,3,1), Right(NºLote,1) & Left(NºLote,2) From CCCit Where [nopartida]='" & [formularios].[Controlcalidadmaster].[nopartida] & "';"

If [nopartida] is a number remove the single quotes. This Query assumes [nopartida] is a string.
0
 

Author Comment

by:maguerez
ID: 11949881
I  have still a syntax error "3144" in your expression and in the one I have slightly modified.



DoCmd.RunSQL "UPDATE CCCit (Productor,NºLote) SET [Productor]= mid([NºLote],3,1),[NºLote]= Right([NºLote],1) & Left([NºLote],2) From CCCit Where [nopartida]= '" & Me.nopartida & "'"
0
 
LVL 44

Accepted Solution

by:
GRayL earned 80 total points
ID: 11956145

I'm not sure if quoting the fields is causing the error: Try:

DoCmd.RunSQL "UPDATE CCCit SET [Productor]= mid([NºLote],3,1),[NºLote]= Right([NºLote],1) & Left([NºLote],2) From CCCit Where [nopartida]= '" & Me.nopartida & "'"
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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.

895 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

19 Experts available now in Live!

Get 1:1 Help Now