Drawing A Picture

CJBIRKIN

Drink!
Local time
Today, 00:28
Joined
May 10, 2002
Messages
255
Hi

I have managed to create a simple bit of code that allows a
picture to be edited, kind of, basically i have a main form and a subform. The subform has an image of a body.

Each time the user clicks the picture on the subform copy is made of the subform and a bitmap of a red dot is added to the copy at the co-ordinates of the click,( this has to be done in design view) the copy is then used to replace the original subform. Each time a the user clicks the picture the previous form is copied and then replaced.

The problem is i want to delete the previous forms as i go along i.e copy--> swap--> delete original. I can't do this whilst the code is running in the original but once the event is complete i can't find another event on the main form that is activated. Any ideas ?

I've enclosed a copy as it should be easier to understand form this.

Thanks

Chris
 
Sorry could have sworn i did!!
 
looks like its to big i've tried twice, and i can't make it any smaller so here is the code.

This is on the sub form

Private Sub IMG_BODY_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

Dim CtlImg As Image
Dim StrPath As String
Dim StrBodyCount As String
IntBodyCount = IntBodyCount + 1

If IntBodyCount = 1 Then
StrBodyCount = ""
Else
StrBodyCount = Trim(Str(IntBodyCount - 1))
End If


' CREATE A COPY OF THE PREVIOUS/UNALTERED FORM
DoCmd.CopyObject "", Trim("FRM_BODY" & IntBodyCount), acForm, Trim("FRM_BODY" & StrBodyCount)


' OPEN THE NEW FORM IN DESIGN VIEW
DoCmd.OpenForm "FRM_BODY" & IntBodyCount, acDesign


' ADD AN IMAGE CONTROL TO THE FORM
Set CtlImg = CreateControl("FRM_BODY" & IntBodyCount, acImage, acDetail, , , X, Y, 50, 50)

' SET THE PICTURE IN THE IMAGE CONTROL
StrPath = Mid(CurrentDb.Name, 1, Len(CurrentDb.Name) - 14)
CtlImg.Picture = StrPath & "dot.BMP"
CtlImg.Name = "IMG" & IntBodyCount

' CLOSE AND SAVE THE NEW FORM
DoCmd.Close acForm, "FRM_BODY" & IntBodyCount, acSaveYes

' SET THE SUBFORM TO THE NEW FORM

Forms!FRM_MAIN!SUBFORM_BODY.SourceObject = "FRM_BODY" & IntBodyCount
End Sub

this is on the main form there is also a global variable in a module
IntBodyCount

Private Sub CMD_RESET_Click()
IntBodyCount = 0
On Error Resume Next
DoCmd.CopyObject , "FRM_BODY", acForm, "FRM_BODY" & IntBodyCount
Me.SUBFORM_BODY.SourceObject = "FRM_BODY"
End Sub

Thanks

Chris
 

Users who are viewing this thread

Back
Top Bottom