Deleting a picture

  • Thread starter Afrosheen via AccessMonster.com
  • Start date
A

Afrosheen via AccessMonster.com

Thanks for reading this and taking the time to answer my question.

I have a form with a employee picture in it. The picture is in another folder.
What I want to do is when I delete the employee record, the picture will also
be deleted.

The structure of the folder is:
C:\NCI Database\NCI Pictures.

A picture name would be something like: SVT.JPG It is based on a field
{StaffId} in the employee table plus JPG. In the same table is the SVT.JPG
under the field called picid.

The table for the employee record is stored at least right now under the NCI
Database.

The code from the form is:

Private Sub delrecord_Click()
10 On Error GoTo Err_delrecord_Click

20 If MsgBox("Do You Really Want to Delete " & Chr(13) & Chr(10) & Chr(13)
& _
UCase([Fname]) & " " & UCase([Lname]) & "?", vbExclamation + vbYesNo) =
vbYes Then
30 DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
40 DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70

50 Else
60 DoCmd.OpenForm "frmyoucoward", acNormal, "", "", acReadOnly, acNormal
70 DoCmd.RepaintObject acForm, "frmyoucoward"


80 End If


Exit_delrecord_Click:
90 Exit Sub

Err_delrecord_Click:

100 If Err.Number <> 2501 Then MsgBox Err.Description
110 Call LogError(Err.Number, Err.Description, "delrecord_click()")
'MsgBox Err.Description
120 Resume Exit_delrecord_Click

End Sub

Any help would be appreciated.

Thanks.
 
J

Jack Leach

put the filename in a variable and use the Kill function


Kill "C:\Myfolder\Myfile.jpg"

hth
--
Jack Leach
www.tristatemachine.com

"I haven't failed, I've found ten thousand ways that don't work."
-Thomas Edison (1847-1931)
 
A

Afrosheen via AccessMonster.com

Thanks Jack for coming back.

Like this?
private sub {something}

dim delname as string
delname = picid
kill "C:\MyFolder\delname

endsub

Is this the correct way?

The picid would = svt01.jpg

Jack said:
put the filename in a variable and use the Kill function

Kill "C:\Myfolder\Myfile.jpg"

hth
Thanks for reading this and taking the time to answer my question.
[quoted text clipped - 46 lines]
 
J

Jack Leach

Almost... beware of string values and quotes. Variables cant have quotes
around them, strings have to. Use the & contencator to combine the two.

dim delname as string
delname = picid
kill "C:\MyFolder\delname

Dim delname as string
delname = picid
kill "C:\MyFolder\" & delname

assuming picid is a string of the filename and portrayed as a variable in
this example. Otherwise use Me.picid for a form or use DLookup or something
to get the string from the datasource.

--
Jack Leach
www.tristatemachine.com

"I haven't failed, I've found ten thousand ways that don't work."
-Thomas Edison (1847-1931)



Afrosheen via AccessMonster.com said:
Thanks Jack for coming back.

Like this?
private sub {something}

dim delname as string
delname = picid
kill "C:\MyFolder\delname

endsub

Is this the correct way?

The picid would = svt01.jpg

Jack said:
put the filename in a variable and use the Kill function

Kill "C:\Myfolder\Myfile.jpg"

hth
Thanks for reading this and taking the time to answer my question.
[quoted text clipped - 46 lines]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top