Solved

String chain and SQL

Posted on 2004-08-31
11
304 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
[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
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 26

Expert Comment

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

An UPDATE query.   :-)
0
 

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

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…
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

732 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