Delete Files Based On a Text Field (1 Viewer)

isladogs

MVP / VIP
Local time
Today, 17:50
Joined
Jan 14, 2017
Messages
18,186
"C:\Folder1\Folder2"
"C:\Folder1\Folder2\ "

Ok if you add a trailing space
How peculiar .... must be a new bug
Moral is of course to always use code tags....
 
Last edited:

Learn2010

Registered User.
Local time
Today, 13:50
Joined
Sep 15, 2010
Messages
415
Here is my last attempt. The control is on a subform.

Start of Code
strCustID = Forms!frmMain!frmMainSub!Form!control

Kill "C:\Folder1\Folder2" & '" & strCustID & "'"
End of Code

I get a syntax error on the second line.
 

Learn2010

Registered User.
Local time
Today, 13:50
Joined
Sep 15, 2010
Messages
415
My mistake. I did.

Kill "C:\Folder1\Folder2" & '" & strCustID & "'"
 

Gasman

Enthusiastic Amateur
Local time
Today, 17:50
Joined
Sep 21, 2011
Messages
14,045
My mistake. I did.

Kill "C:\Folder1\Folder2" & '" & strCustID & "'"

As has been amply demonstrated, the site removes the last backslash if in quotes and not in code tags.

If you post within code tags and copy and paste the code we can see exactly what you have.

FWIW although it is a string I would have stuck with

Code:
Kill "C:\Folder1\Folder2\" & lngCustID
and assigned CustomerID to lngCustID

Gets rid of all the quote matching?
 

RuralGuy

AWF VIP
Local time
Today, 11:50
Joined
Jul 2, 2005
Messages
13,826
Highlight your code and then press the "#" sign in the tool bar.
 

isladogs

MVP / VIP
Local time
Today, 17:50
Joined
Jan 14, 2017
Messages
18,186
I used them in post 3.
To do so, use the # button in the toolbar above your post.
If you can't see it, click the Advanced button

Example:

Code:
strCustID = Forms!frmMain!frmMainSub!Form![COLOR="Red"]control[/COLOR]

Kill "C:\Folder1\Folder2\" & '" & strCustID & "'"

The first line of code is referencing a control in a subform from the main form.
However I'm sure you don't have a control called control.
Use the actual control name instead
If it is called 'control', rename it or you'll have loads of problems
 

Learn2010

Registered User.
Local time
Today, 13:50
Joined
Sep 15, 2010
Messages
415
#
strCustID = Forms!frmMain!frmMainSub!Form!control Kill "C:\Folder1\Folder2" & '" & strCustID & "'"
#

Like this?

Also, the control is not named control
 

isladogs

MVP / VIP
Local time
Today, 17:50
Joined
Jan 14, 2017
Messages
18,186
#
strCustID = Forms!frmMain!frmMainSub!Form!control Kill "C:\Folder1\Folder2" & '" & strCustID & "'"
#

Like this?

Also, the control is not named control

NO
To do so, use the # button in the toolbar above your post.
If you can't see it, click the Advanced button

And I don't suppose its Folder1 or Folder2 either.
Please don't rename items. It doesn't help. In fact it just causes confusion.
 

Learn2010

Registered User.
Local time
Today, 13:50
Joined
Sep 15, 2010
Messages
415
Got it.

Code:
strCustID = Forms!frmMain!frmMainSub!Form![COLOR=Red]controlname[/COLOR] 
 Kill "C:\Folder1\Folder2\ " & '" & strCustID & "'"
 

isladogs

MVP / VIP
Local time
Today, 17:50
Joined
Jan 14, 2017
Messages
18,186
And you've got the code tags too....

Now if that is called controlname, please rename it
If not, see my previous comment about using actual names.
 

Gasman

Enthusiastic Amateur
Local time
Today, 17:50
Joined
Sep 21, 2011
Messages
14,045
OK, think about what you are trying to get and what you have.?

You have coded for a space after the last backslash.?
Do you ever see that in real life?

Then as it is a string it just needs to be added to the first string?
Code:
"C:\Folder1\Folder2\"

then we need the variable

Code:
"C:\Folder1\Folder2\" & strCustID



Got it.

Code:
strCustID = Forms!frmMain!frmMainSub!Form![COLOR=Red]controlname[/COLOR] 
 Kill "C:\Folder1\Folder2\ " & '" & strCustID & "'"
 

Users who are viewing this thread

Top Bottom