Solved Remove certain parts of a concatenated textbox (1 Viewer)

BenMason

Member
Local time
Yesterday, 20:18
Joined
May 14, 2021
Messages
37
I have a form with a concatenated textbox with string information separated by a comma. Example: (2)01-1210,(6)388108,(4)75342
(2) within the parenthesis is the qty, and the remaining number is the part#. There can be a string one or more of this qty and part # separated by a comma.
When I click a minus button on the form, I have already saved the qty without the parenthesis and the part# in a separate string. strQty, strPart. I want to remove the qty, the parenthesis on both sides of qty, the part#, and the comma Ex: (6)388108, from the concatenated textbox based on the separate string information I have saved.
I need to grab and delete it in whatever position it is within the textbox. The position doesn't matter.
I'm unsure how to identify it and delete only the values I have stored in my strQty and strPart from the concatenated textbox and delete the parentheses and comma.

Your help is greatly appreciated.

Thanks,
Ben
 
What do you mean by "concatenated textbox"? Is this value produced by an expression concatenating multiple fields? Or is this CSV data saved in a single field in table?
 
What do you mean by "concatenated textbox"? Is this value produced by an expression concatenating multiple fields? Or is this CSV data saved in a single field in table?
Sorry, concatenated data with a textbox. It's an MS Access textbox where previously, the data was put in the textbox in a string to add multiple parts and quantity. Now, I have a button on the form and want to delete certain ones from the textbox. Leaving the data concatenated for the remaining data.
 
Sorry, concatenated data within a textbox and that data is saved in the table that way. It's an MS Access textbox where previously, the data was put in the textbox in a string to add multiple parts and quantity. Now, I have a button on the form and want to delete certain ones from the textbox. Leaving the data concatenated for the remaining data.
 
here is a demo, open Form1, view the vba behinde the "Split" button.
 

Attachments

here is a demo, open Form1, view the vba behinde the "Split" button.
Arnelgp, I see that I didn't explain it well. The button on my form is a delete button. I want to delete only one(1) of the three parts. for instance the (6)388108, from the textbox. I know and have saved that the qty is 6 and the part is 388108 when I click the delete button.

I see how you removed the parenthesis. I think I can use that to remove it from (6), but it should remain for the other part values.
So that after it is done, the textbox will look like this: (2)01-1210,(4)75342

Thanks,
Ben
 
oww, here is another modified demo.
you first highlight (using the mouse) the quantity and the part# to be deleted.
then press the Delete(-1) button.

//Edit you can modify the MouseUp button to only use .SelText
Code:
Private Sub txtSample_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
txtSelected = Me.txtSample.SelText
End Sub
 

Attachments

Last edited:
oww, here is another modified demo.
you first highlight (using the mouse) the quantity and the part# to be deleted.
then press the Delete(-1) button.
This works perfectly! Exactly what I needed.
Thank you for your quick response.

Ben
 
With this sort of thing, it's good if you can get a standard storage mechanism.

Instead of using the parentheses, give the values a separate comma separator.

So you get 2, part number 1, 6, part number 2, 8, part number 3

This way it probably becomes easier to process. You have to realise you are really using a string to simulate a structured record that could be held in a linked table. If you are regularly having to manipulate the string it might be worth splitting it off into a linked table.

In your case if some records have 3 sections in the string, and others only have 2, does that always mean the string has been processed according to your rules? Can you have records with different numbers of sections. Could you achieve the same result by just updating the number in the brackets to 0, for instance?
 

Users who are viewing this thread

Back
Top Bottom