Solved

Need helping formatting text field in SQL statement

Posted on 2013-01-18
4
326 Views
Last Modified: 2013-01-18
I have a query:

strPID = "DELETE * FROM tblPID WHERE PID = '" & !RF_PID & "' AND SECT = '" & Format(!RF_SECT, "0") & "';"

Fields RF_SECT and SECT are each two characters wide and can accept values from 01 - 99. Each have to be a text field.

Works fine most of the time, however sometimes the field SECT has data in it formatted with a zero place holder.

Unfortunately there is no way that I can access all sources of data and change it to remove the place holder Zero.

How could I rewrite this statement so that if the leading character in the field SECT is a zero that it would be ignored? RF_PID always has the zero place place holder.

To explain by example:

SECT | RF_SECT
---------------------
1  | 01
02 | 02
3 | 03
4 | 04
05 | 05

Each one has to match the other and I do no know how to catch it.
0
Comment
Question by:PBLack
  • 2
4 Comments
 
LVL 32

Assisted Solution

by:awking00
awking00 earned 200 total points
ID: 38793932
where replace(rf_sect,'0','') = replace(sect,'0','')
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 300 total points
ID: 38793940
this will do it

where replace(rf_sect,"0","",1,1)= replace(sect,"0","",1,1)

it will replace ONLY the first "0" in the First position and only one 0
0
 

Author Closing Comment

by:PBLack
ID: 38793996
Thanks
0
 
LVL 32

Expert Comment

by:awking00
ID: 38794172
Would it matter if where 20 = 20 becomes where 2 = 2? Just curious.
0

Featured Post

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

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

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

679 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