473,394 Members | 1,812 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Problem with searching due to spaces

Hi there,
I had wrote a program using vb that take this Input string "061003C1DBN11N100MACH1" (without spaces) from Barcode Scanner in order to find the String "B 061003C1 DBN1 1 N100 MACH1" (with spaces) in MS Access Database. However it doens't match the record due to the spaces.
It only works if i spacing the input string like in the format in database. Any suggestion on solving this problem? Thanks

This is the search code that i used

'BarcodeSearch_form.Show

Private Sub BarcodeSearch_Click()

Dim strBarcode As String
Dim strSQL As String

'Perform Barcode Search

strBarcode = Barcode.Text

'Show the specimen status with the relevant Barcode
strSQL = "SELECT SpecimenName, Company, Material, Test, C/A, SpecsNeeded, Project, Status, Date, Time FROM Tracking WHERE AssignmentString= '" & strBarcode & "'"
AdodcBarcode.RecordSource = strSQL
AdodcBarcode.Refresh
BarcodeSearch_form.Hide
BarcodeResult_form.Show


End Sub
Nov 20 '06 #1
7 1298
sashi
1,754 Expert 1GB
Hi there,
I had wrote a program using vb that take this Input string "061003C1DBN11N100MACH1" (without spaces) from Barcode Scanner in order to find the String "B 061003C1 DBN1 1 N100 MACH1" (with spaces) in MS Access Database. However it doens't match the record due to the spaces.
It only works if i spacing the input string like in the format in database. Any suggestion on solving this problem? Thanks

This is the search code that i used

'BarcodeSearch_form.Show

Private Sub BarcodeSearch_Click()

Dim strBarcode As String
Dim strSQL As String

'Perform Barcode Search

strBarcode = Barcode.Text

'Show the specimen status with the relevant Barcode
strSQL = "SELECT SpecimenName, Company, Material, Test, C/A, SpecsNeeded, Project, Status, Date, Time FROM Tracking WHERE AssignmentString= '" & strBarcode & "'"
AdodcBarcode.RecordSource = strSQL
AdodcBarcode.Refresh
BarcodeSearch_form.Hide
BarcodeResult_form.Show


End Sub
Hi there,

Refer to below code segment, does it rings any bell. Hope it helps. Good luck & Take care.

Expand|Select|Wrap|Line Numbers
  1.   Dim txt As String
  2.  
  3.   txt="This is a beautiful day!"
  4.   msgbox (Left(txt,11))
  5.  
Kindly refer to below attached link for further reading & understanding.

http://msdn2.microsoft.com/en-us/lib...wb(VS.80).aspx
Nov 20 '06 #2
willakawill
1,646 1GB
Hi there,
I had wrote a program using vb that take this Input string "061003C1DBN11N100MACH1" (without spaces) from Barcode Scanner in order to find the String "B 061003C1 DBN1 1 N100 MACH1" (with spaces) in MS Access Database. However it doens't match the record due to the spaces.
It only works if i spacing the input string like in the format in database. Any suggestion on solving this problem? Thanks

This is the search code that i used

'BarcodeSearch_form.Show

Private Sub BarcodeSearch_Click()

Dim strBarcode As String
Dim strSQL As String

'Perform Barcode Search

strBarcode = Barcode.Text

'Show the specimen status with the relevant Barcode
strSQL = "SELECT SpecimenName, Company, Material, Test, C/A, SpecsNeeded, Project, Status, Date, Time FROM Tracking WHERE AssignmentString= '" & strBarcode & "'"
AdodcBarcode.RecordSource = strSQL
AdodcBarcode.Refresh
BarcodeSearch_form.Hide
BarcodeResult_form.Show


End Sub
Hi. Does the format of the spaced string always remain constant i.e.
1 character + 8 characters + 4 characters etc?
Nov 20 '06 #3
Hi. Does the format of the spaced string always remain constant i.e.
1 character + 8 characters + 4 characters etc?

Yes...its a constant naming format. (1 character + 8 characters + 4 characters+1 charachers+4 characthers+ 5 characthers)
(B 061003C1 DBN1 1 N100 MACH1)
every string will be in such format in database.
Nov 20 '06 #4
sashi
1,754 Expert 1GB
Yes...its a constant naming format. (1 character + 8 characters + 4 characters+1 charachers+4 characthers+ 5 characthers)
(B 061003C1 DBN1 1 N100 MACH1)
every string will be in such format in database.
Hi there,

In that case, the Left() function will do the work, hope it helps. Good luck & take care.
Nov 20 '06 #5
Sashi... i knew that command it just trim away sumthing that u dun wan but it doesn't apply to my situation. Anyway thanks for ur help!
maybe i didn't explain very clear at the first place, i'm having problems to match the input string "061003C1DBN11N100MACH1" (without spaces) with the strings in ms access database "B 061003C1 DBN1 1 N100 MACH1" (with spaces) to perform a search The spaces in between the stings in Ms Access is causing the problem.

P.S. The input format (without spaces) will be constant like that and so as the database (with spaces).

So should i wrote a code to add spaces in between for the input string or any better code for the SQL search? Or perhaps something i should modify in ms access? Really appreciated ...Thanks!
Nov 20 '06 #6
Killer42
8,435 Expert 8TB
If the format of the input and the database entries are always going to remain constant, then at the simplest you have two options.

(1)
Modify your database entries (or more likely, add another field) to hold the same format as the input, or

(2)
Reformat the scanner input to match the database entries.

Personally I think that option 2 makes more sense.

Option 1 would require you to either use up more storage space (minor concern I know, but it is there) or reformat whenever you pull the value out of the database for any other purpose.

Option 2, on the other hand, requires only a simple reformat (probably one statement concatenating a few Left( ) and Mid( ) values at the time you receive the scanner input). In fact, here's a function which should do it...
Expand|Select|Wrap|Line Numbers
  1. Public Function SpacedOut(ByVal ScannerInput As String) As String
  2. SpacedOut = "B " & Left(ScannerInput, 8) & " " & Mid(ScannerInput, 9, 4) & " " & Mid(ScannerInput, 13, 1) & " " & Mid(ScannerInput, 14, 4) & " " & Mid(ScannerInput, 18)
  3. End Function
There might also be some way to use regular expressions to do the match, but I'm not sure.
Nov 20 '06 #7
If the format of the input and the database entries are always going to remain constant, then at the simplest you have two options.

(1)
Modify your database entries (or more likely, add another field) to hold the same format as the input, or

(2)
Reformat the scanner input to match the database entries.

Personally I think that option 2 makes more sense.

Option 1 would require you to either use up more storage space (minor concern I know, but it is there) or reformat whenever you pull the value out of the database for any other purpose.

Option 2, on the other hand, requires only a simple reformat (probably one statement concatenating a few Left( ) and Mid( ) values at the time you receive the scanner input). In fact, here's a function which should do it...
Expand|Select|Wrap|Line Numbers
  1. Public Function SpacedOut(ByVal ScannerInput As String) As String
  2. SpacedOut = "B " & Left(ScannerInput, 8) & " " & Mid(ScannerInput, 9, 4) & " " & Mid(ScannerInput, 13, 1) & " " & Mid(ScannerInput, 14, 4) & " " & Mid(ScannerInput, 18)
  3. End Function
There might also be some way to use regular expressions to do the match, but I'm not sure.
Thanks.. Killer42.. Ur Option2 is wat i'm looking for... Really appreciate ur help and for those who offerec help in this thread too..
:)
Nov 20 '06 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

12
by: rbt | last post by:
Not really a Python question... but here goes: Is there a way to read the content of a PDF file and decode it with Python? I'd like to read PDF's, decode them, and then search the data for certain...
2
by: ajitgoel | last post by:
Hi; I need some simple help with my regular expressions. I want to search my input text for all the boolean variables which do not start with bln. i.e I want to match "bool followed by 1 or...
2
by: Frank Millman | last post by:
Hi all I have found a problem using MS Sql Server connecting via the odbc module from python-win32. I am liaising with Mark Hammond, and he is trying to help, but he is very busy, and I...
4
by: Jordan S. | last post by:
Using .NET 2.0 (C#) I'm writing a small app that will have a "Person" class that exposes FirstName and LastName properties. At runtime, a "People" collection will be populated with a few thousand...
1
by: Tim | last post by:
I ran into a problem with a script i was playing with to check code indents and need some direction. It seems to depend on if tabsize is set to 4 in editor and spaces and tabs indents are mixed on...
11
by: Lothar Behrens | last post by:
Hi, I have selected strtok to be used in my string replacement function. But I lost the last token, if there is one. This string would be replaced select "name", "vorname", "userid",...
5
by: Raj | last post by:
Following is a code to replace blanks in entered string with adequate number of tabs & spacings as required. I've taken the width of tab as 5 characters here. The problem that occurs here is for...
1
by: SSJVEGETA | last post by:
Hello, everybody. I have read some examples and manuals for the egrep command for Linux and I don't know if this egrep command is right for the particular files I am searching for. Here is what the...
13
by: Rafe | last post by:
Hi, I am in a situation where I feel I am being forced to abandon a clean module structure in favor of a large single module. If anyone can save my sanity here I would be forever grateful. My...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.