Hello, I am having a problem trying to write a procedure that will search for files that I have saved and display them. I save my files with a zip code and a customer number, so that they could be looked up by any of these two ways.
Here is the code that I used to save it. Any help with going in the right direction would be greatly appreciated.
Public Sub Save()
'This checks to make sure that there is text
'in the customer number and zip text box.
If txtCustomerNumber.Text = "" And txtZip.Text = "" Then
MsgBox "Customer Number or Zip Code" & vbCrLf _
& "must be filled in."
Exit Sub
End If
'This saves the file by customer number
If txtCustomerNumber.Text <> "" Then
Open "C:\STI\Customers\" & UCase$(txtCustomerNumber.Text) For Output As #1
Write #1, "Facility: " & UCase$(txtName.Text), "Date: " & UCase$(txtDate.Text)
Write #1, "Address: " & UCase$(txtAddress.Text), "City: " & UCase$(txtCity.Text), "State: " & UCase$(txtState.Text), _
"Zip: " & txtZip.Text
Write #1, "Phone: " & txtPhone.Text, "Fax: " & txtFax.Text, "Email: " & txtEmail.Text
Write #1, "Customer# " & UCase$(txtCustomerNumber.Text)
Write #1,
Write #1, "Comments:"
Write #1, UCase$(txtComments.Text)
Write #1,
Write #1,
Close #1
End If
'This saves the file by zip code
If txtZip.Text <> "" Then
Open "C:\STI\Customers\" & UCase$(txtZip.Text) For Output As #1
Write #1, "Facility: " & UCase$(txtName.Text), "Date: " & UCase$(txtDate.Text)
Write #1, "Address: " & UCase$(txtAddress.Text), "City: " & UCase$(txtCity.Text), "State: " & UCase$(txtState.Text), _
"Zip: " & txtZip.Text
Write #1, "Phone: " & txtPhone.Text, "Fax: " & txtFax.Text, "Email: " & txtEmail.Text
Write #1, "Customer# " & UCase$(txtCustomerNumber.Text)
Write #1,
Write #1, "Comments:"
Write #1, UCase$(txtComments.Text)
Write #1,
Write #1,
Close #1
End If
End Sub
Here is the code that I used to save it. Any help with going in the right direction would be greatly appreciated.
Public Sub Save()
'This checks to make sure that there is text
'in the customer number and zip text box.
If txtCustomerNumber.Text = "" And txtZip.Text = "" Then
MsgBox "Customer Number or Zip Code" & vbCrLf _
& "must be filled in."
Exit Sub
End If
'This saves the file by customer number
If txtCustomerNumber.Text <> "" Then
Open "C:\STI\Customers\" & UCase$(txtCustomerNumber.Text) For Output As #1
Write #1, "Facility: " & UCase$(txtName.Text), "Date: " & UCase$(txtDate.Text)
Write #1, "Address: " & UCase$(txtAddress.Text), "City: " & UCase$(txtCity.Text), "State: " & UCase$(txtState.Text), _
"Zip: " & txtZip.Text
Write #1, "Phone: " & txtPhone.Text, "Fax: " & txtFax.Text, "Email: " & txtEmail.Text
Write #1, "Customer# " & UCase$(txtCustomerNumber.Text)
Write #1,
Write #1, "Comments:"
Write #1, UCase$(txtComments.Text)
Write #1,
Write #1,
Close #1
End If
'This saves the file by zip code
If txtZip.Text <> "" Then
Open "C:\STI\Customers\" & UCase$(txtZip.Text) For Output As #1
Write #1, "Facility: " & UCase$(txtName.Text), "Date: " & UCase$(txtDate.Text)
Write #1, "Address: " & UCase$(txtAddress.Text), "City: " & UCase$(txtCity.Text), "State: " & UCase$(txtState.Text), _
"Zip: " & txtZip.Text
Write #1, "Phone: " & txtPhone.Text, "Fax: " & txtFax.Text, "Email: " & txtEmail.Text
Write #1, "Customer# " & UCase$(txtCustomerNumber.Text)
Write #1,
Write #1, "Comments:"
Write #1, UCase$(txtComments.Text)
Write #1,
Write #1,
Close #1
End If
End Sub