How to click on an image to enter data in table

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How would I click on an image of a floor map to enter that room number in a
text field of a form?
 
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.
 
Back
Top