Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating a clickable image 3

Status
Not open for further replies.

MindGrove

IS-IT--Management
Jul 1, 2009
5
GB
In a MS Access 2007 database I have placed on a form an image. It's a square five-by-five grid made up of twenty five equal sized squares. A bit like a chessboard but with fewer squares.

What I would like to do next is two fold.

1) Allow the user of the form to point to one of the grid's squares and select it - I need the square's x and y co-ordinates when they do this so that I can store these values for the next time they return to this particular form.

2) Put a mark (dot, circle or the like) on the grid in the selected square so that there is visual feedback to the user of the selection made.

I'm looking for startup clues on how to go about this task. I have limited knowledge of MS Access 2007 but need a push in the right direction.

Regards,

Henry
 
Hallo,

From memory, the MouseDown event gives you an X and Y coordinate (relative to the control) so you can calculate the coordinates from that.
I can't remember whether the X is the horizontal or vertical axis tho.
Divide X by the Width of the control and multiply by the no of grid squares (5) and lose the fractional part to give you value from 0 to 4. You may have to mess about with limits (X<0, X>Width etc), or that may only be with MouseMove.

You can create a marker control (rectangle?) the size of a square in your grid and set its top and left properties to values based on the calculated X and Y.
You'll have to be careful as it might take the focus or something...

That's how I'd start looking at the problem,


- Frink
 
How are ya MindGrove . . .

I'm beliving you used the [blue]Rectangle Tool[/blue] to make the boxes. So to answer your questions:
You don't need to save the xy positions. You can save the boxname if it was selected. Selections ae made my changing the backcolor of the box ... which can be a toggle. Click On ... again to Click Off.

If you give the boxes simple names like:
[tt] B11 B12 B13 B14 B15
B16 B17 B18 B19 B20
B21 B22 B23 B24 B25
B26 B27 B28 B29 B30
B31 B32 B33 B34 B35[/tt]
If should be easy enough to pack all selections in a single string!

[blue]Your Thoughts? . . .[/blue]

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Thanks, Frink and the AceMan1 these are both very helpful ideas and something I can work on.

One thought that came to me, would it also be possible to put a button (transparent if possible?) over each square and create an action, such as setting a value, when the button is pushed?

regards

Henry

 
See if this works for you.

This uses toggle buttons. You do not need an image, but I allow you to put one if you want. For the demo to work put a small image in your c: drive and call it "1.Bmp". If you do not want to use an image comment out these two pieces of code.

ctrl.Picture = ""
ActiveControl.Picture = "C:\1.BMP"
 
Majp,

That is the final piece in the jig-saw puzzle! Many thanks and thanks to the earlier contributors too.

Rgards,

Henry
 
here is a mod

Private Sub unclickToggles()
Dim ctrl As Access.Control
For Each ctrl In Me.Controls
If ctrl.ControlType = acToggleButton Then
ActiveControl.Picture = "C:\1.BMP"
If (ctrl = -1 And Not ctrl.Name = ActiveControl.Name) Then
ctrl = 0
ctrl.Picture = ""
End If
If ActiveControl = 0 Then
ActiveControl.Picture = ""
End If
End If
Next ctrl
End Sub


This is the case where you untoggle the current selection. It gets rid of the image.
 
MindGrove . . .

Instead of the button ... you could just use the [blue]Double Click[/blue] event of each box to do the same! [thumbsup2]

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top