# Visual Basic > Office Development >  drawing in Access

## wengang

Pretty sure this is a hard no.
Is there a way to draw in Access?
In VB6, I built a Paint clone years ago, but all I'm trying to do is have one picture box (or whatever) where mouse down, mousemove, and mouse up combine with some kind of small lines or even dots (assuming there's no painting allowed in Access) to draw on the control.
It doesn't have to be elaborate.  It can't e a third party or ActiveX control.  It has to be native.
Thanks.

----------


## jdc2000

Possibly useful links, if you have not already seen them:

https://social.msdn.microsoft.com/Fo...orum=vbgeneral

https://social.msdn.microsoft.com/Fo...forum=winforms

https://social.msdn.microsoft.com/Fo...orum=vbgeneral

https://social.msdn.microsoft.com/Fo...orum=vbgeneral

https://social.msdn.microsoft.com/Fo...artdevicesvbcs

----------


## wengang

Well, I didn't think anybody would reply that quickly.
I decided to try out my crude dot idea, and had some early success.
If anybody wants to replicate it, pretty simple (and if you can improve it, by all means).
On a form put a small black rectangle (like 0.04"), invisible border, solid backcolor (black or whatever), visible = false.
Copy and paste until there are 500 of them (again, or whatever).
Put an image box on the form, in my case a couple of inches square, I called mine imgPalette.
In the form's code, up top dim these variables:
Dim MyPixel(1 To 500) As Rectangle
Dim tPixel As Integer, lastX As Integer, lastY As Integer

In the Form_Load event, paste this
For t = 1 To 500
Set MyPixel(t) = Controls("Box" & t + 29) 'my boxes were Box30 to Box529, adjust to your numbers
Next
tPixel = 0

Now you just need a mousemove event sub for imgPalette:

Private Sub imgPalette_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 0 Then Exit Sub
If X < 0 Or X > imgPalette.Width Then Exit Sub
If Y < 0 Or Y > imgPalette.Height Then Exit Sub
If X <> lastX Or Y <> lastY Then 'moved
tPixel = tPixel + 1
MyPixel(tPixel).Left = imgPalette.Left + X
MyPixel(tPixel).Top = imgPalette.Top + Y
MyPixel(tPixel).Visible = True
End If
lastX = X 'for next round
lastY = Y
End Sub


Lastly, I put in a command button to erase and start over:

Private Sub Command530_Click()
For t = 1 To 500
MyPixel(t).Visible = False
Next
tPixel = 0
End Sub


It's crude, but it's a start.  Anybody else?

----------


## Dan_W

I'm not very familiar with the Access flavour of VBA, and I know that it has more controls available to it (including the Picturebox?) than the rest of the Office Suite does, but I do know that you have the Userform, and as long as you have that (at least), you have access to the WIN32APIs, in which case you can definitely draw/animate, etc.

An example is the painting program made by Jaafar T on Mr Excel - https://www.mrexcel.com/board/thread...rawing.950704/ 
It may need some adjustments to be Access-friendly - I haven't looked at the code in a while, but if it does need some adjustment, it shouldn't be overly problematic.

----------

