Results 1 to 4 of 4

Thread: drawing in Access

  1. #1

    Thread Starter
    Frenzied Member wengang's Avatar
    Join Date
    Mar 2000
    Location
    Beijing, China
    Posts
    1,588

    drawing in Access

    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.
    Wen Gang, Programmer
    VB6, QB, HTML, ASP, VBScript, Visual C++, Java

  2. #2

  3. #3

    Thread Starter
    Frenzied Member wengang's Avatar
    Join Date
    Mar 2000
    Location
    Beijing, China
    Posts
    1,588

    Re: drawing in Access

    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?
    Wen Gang, Programmer
    VB6, QB, HTML, ASP, VBScript, Visual C++, Java

  4. #4
    Member
    Join Date
    May 2021
    Posts
    35

    Re: drawing in Access

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width