Solved

String chain and SQL

Posted on 2004-08-31
11
264 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
Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

 

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Familiarize people with the process of utilizing SQL Server functions 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 Ac…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

707 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

17 Experts available now in Live!

Get 1:1 Help Now