How to click on an image to enter data in table

M

mtarabochia

How would I click on an image of a floor map to enter that room number in a
text field of a form?
 
D

Duane Hookom

You could use the mouse position. Consider the following sample:
-Place an image on a form and name the image control "imgMyImage"
-Place to text boxes on the form
Name: txtMouseX
Name: txtMouseY
-Add this code to the Mouse Move event of imgMyImage

Private Sub imgMyImage_MouseMove(Button As Integer, _
Shift As Integer, X As Single, Y As Single)
Me.txtMouseX = X
Me.txtMouseY = Y
End Sub

and this code to the On Click event:

Private Sub imgMyImage_Click()
MsgBox "Mouse X: " & Me.txtMouseX & vbCrLf & _
"Mouse Y: " & Me.txtMouseY, _
vbOKCancel + vbInformation, "Your Coordinates"
End Sub

Your room table would need to store its min and max X and Y values. This
would allow you to trap the current X and Y so you could query the room
table for the proper room number.

I expect you could use similar code as above to populate the values in the
room table.
 

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