Forum

Obtain the customer...
 
Notifications
Clear all

Obtain the customer's voices from a TXT file, each in their own Textbox

8 Posts
2 Users
0 Reactions
86 Views
(@a-maurizio)
Posts: 214
Reputable Member
Topic starter
 

Hello my name is Maurizio and my problem with excel and its VBA and this:
I plugged in a Userform 11 Textbox and two Buttons I respectively called "Weld Data"
and "Find Customer"

Now I state that this code I had written many years ago using the VB 6.0 and it is working
today again.

Now having said that making changes alqune the case I was able to recreate all using
VBA.

The purpose of my program, and I write for each customer personal data within
the TextBox, After that, we press the "Weld Data" button and all the data entered in Textbox
They Are Saved in a TXT file.

After that my problem and then basically this: I wish that after Submitted
in Textbox1 I Textbox2 or Textbox3 Code (ID) rather than the (Last) or (name) of
Customer from Search, and then pressing the "Find Customer button", I could
appear all record of that customer.

Now I have to admit that as far as the key "Weld Data" in TXT format should I say
Everything works fine well.

But I can not say the same thing regarding the button "Find Customer"; Since all
of that particular customer record can find it all.
However, he removed the first two Textbox, All other They import the same data across the reportt of
that customer.
While I wish that each item returned in the appropriate textbox, the code in question is this:

 

Private Sub Cmd_Salva_Dati_Click()
myFile = ThisWorkbook.Path & "Database.txt"
Open myFile For Append As #1
Write #1, TextBox1, TextBox2, TextBox3
Debug.Print , TextBox1, TextBox2, TextBox3

Close #1
Me.TextBox1.SetFocus

Me.TextBox1.Text = ""
Me.TextBox1.Text = ""
Me.TextBox1.Text = ""
End Sub

Private Sub Cmd_Trova_Cliente_Click()
ChDir ThisWorkbook.Path
myFile = ThisWorkbook.Path & "Database.txt"
'myFile = Application.GetOpenFilename("File di testo,*.txt")
If myFile = "Falso" Then
MsgBox "Nessun file selezionato.", vbCritical + vbOKOnly, "Attenzione"
Exit Sub
End If

Open myFile For Input As #1
Do Until (EOF(1))
Line Input #1, Stringa
If InStr(Stringa, UserForm1.TextBox1) > 0 Then
'Stop
A = InStr(Stringa, ",")
B = InStr(A + 1, Stringa, ",")
C = B - A

D = B - A
E = B - A
F = B - A

G = B - A
H = B - A
I = B - A
J = B - A
K = B - A

TextBox2 = Replace(Mid(Stringa, A + 1, C - 1), """", "")
TextBox3 = Replace(Mid(Stringa, B + 1), Chr(34), "")

TextBox4 = Replace(Mid(Stringa, A + 1, C - 1), """", "")
TextBox5 = Replace(Mid(Stringa, B + 1), Chr(34), "")

TextBox6 = Replace(Mid(Stringa, A + 1, C - 1), """", "")
TextBox7 = Replace(Mid(Stringa, B + 1), Chr(34), "")

TextBox8 = Replace(Mid(Stringa, A + 1, C - 1), """", "")
TextBox9 = Replace(Mid(Stringa, B + 1), Chr(34), "")

TextBox10 = Replace(Mid(Stringa, A + 1, C - 1), """", "")
TextBox11 = Replace(Mid(Stringa, B + 1), Chr(34), "")

GoTo Esci
End If
Loop
Esci:
Close #1

End Sub

 

Could you help me out on this, Thanks Sincere greetings from A.Maurizio

 
Posted : 07/12/2016 5:06 am
(@sunnykow)
Posts: 1417
Noble Member
 

Hi Maurizio

Not too sure if I understood your problem correctly i.e. add data is OK, viewing data is not OK.

You can give the attached a try. I have modified your codes and the userform. I have added some basic validations to the form as well.

It should now work for all the 11 text boxes.

Hope this helps.

Sunny

 
Posted : 08/12/2016 2:12 am
(@a-maurizio)
Posts: 214
Reputable Member
Topic starter
 

Hello SunnyKow First I want to congraturarmi with you, not only for your timeliness in responding; But also for your creation that you gave me.
But there is a problem and it is this: I've wanted to slightly modify your program to adapt it to my needs.
And practical breastfeeding I noticed that if you try to enter the code in Textbox1 (0001 until 0003) it all works beautifully.
The problem arises when: inmetti Code (0004 onwards)
as it gives me errorere here:

Input #1, Stringa, A, B, C, D, E, F, G, H, I, J, K, L, M, N

However no problem because I send you both your program with my latest changes, and also the TXT file with the test fictitious data.
Go ahead calmly thanks for your help.
Sincere greetings from A.Maurizio

 
Posted : 08/12/2016 6:44 am
(@sunnykow)
Posts: 1417
Noble Member
 

Hello Maruzio

There are a few problems that I discovered.

1) Your text file data is inconsistent.

Record 1 and 2 contains only 15 fields but record 3 onward contains 16 field each.

Add an additional blank field ( ,"" ) after "DDDD" to these two records (like below) to make it 16 fields.

"0001","Maurizio","Anietti","Via Giovanni Ungaretti 3","Torino","X","393.38.32.667","x","x","[email protected]","Direttore Musicale","AAA","BBB","CCC","DDDD",""
"0002","Gina","Agamennone","Via sebastiano Rea 12","Ivrea","011.21.66.38","340.88.20.278","x","x","[email protected]","Mamma Maury","AAAA","BBB","CCCC","DDDD",""

 

2) Your userform will also need to add another Textbox16

Adjust the VBA codes to cater for this additional textbox.

 

This will solve your problem.

Cheers

Sunny

 
Posted : 08/12/2016 11:28 am
(@sunnykow)
Posts: 1417
Noble Member
 

Hello Maruzio

I have attached the modified file. I have included an import text function.

Enjoy

Sunny

 
Posted : 08/12/2016 9:45 pm
(@a-maurizio)
Posts: 214
Reputable Member
Topic starter
 

Hello SunnyKow First I must say you've done a nice job.
Then I must say that the fact that you in my TXT has found a field of 16 entries; Rather than 15, you're right as having given everything in hand to do before, I may have Prevo a mistake with all those quotes etc ....!
But the fields to be taken into consideration are only and always 15.
That said: I do not understand why you definitely will work throughout esclusuvamente beneMa me continues to give me error here:

Input #1, Stringa, A, B, C, D, E, F, G, H, I, J, K, L, M, N

He tells me: ("Input past End Of File") why and how I can remedy this inconvegnente, Thank you Bravissimo

 
Posted : 09/12/2016 7:19 am
(@sunnykow)
Posts: 1417
Noble Member
 

Hi Maruzio

I thought you wanted 16 fields that's why I changed to 16.

Attached will work for 15 fields.

Sunny

 
Posted : 09/12/2016 11:16 am
(@a-maurizio)
Posts: 214
Reputable Member
Topic starter
 

Six Fantastic SunnyKow and as herself had wanted me to make a nice Christmas gift and Gorgeous.
Many thanks and a Merry end Week A.Maurizio

 
Posted : 09/12/2016 4:29 pm
Share: