?
Solved

String chain and SQL

Posted on 2004-08-31
11
Medium Priority
?
316 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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 320 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

777 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