Full Version: Using hyperlinks to open forms
UtterAccess Forums > Microsoft® Access > Access Forms
simoncash
Hi,
I am using hyperlinks to open forms and I want the text of the control to change color when the mouse moves over it and change back to its original colour when it moves away. Their does not seem to be a suitable event to capture this. Any suggestions
GlenKruger
Try using the mouse move event to change the color.
simoncash
Thanks, I did try using mouse move but the color wont change back it stays fixed as the new colour
GlenKruger
You have to check to see what color it is and change accordingly.
niesz
I believe you have to use the form's MouseMove event to change it back when you move off the control.
AQM_UK
Hi simon.
The nice thing about hyperlinks is that the cursor changes to the finger point when you mouse over.
However, like all hyperlinks, the colour will turn from blue to purple (default) once the hyperlink is activated.
So, question. Whay are you using hyperlinks. Why not code this into the on click event of the command button?
Then, you can programme in the mouse move of the control to change the colour of the text as you move over.
HTH
Jim
Candace Tripp
CODE
  Private Sub Detail_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
On Error Resume Next
nbsp;   Me.FormLink.ForeColor = vbBlue
End Sub
Private Sub Form_Load()
On Error Resume Next
    Me.FormLink.ForeColor = vbBlue
End Sub
Private Sub FormLink_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
On Error Resume Next
    Me.FormLink.ForeColor = vbMagenta
        
End Sub
simoncash
Hi Jim,
usually use command buttons in previously designed applications but this time I decided to try hyperlinks as I had read that they were a code efficient way of opening forms. I also wanted to create a more web-based application style interface, hence the hyperlinks.
Cheers,
Simon.
simoncash
Thanks very much Candace that is exactly what I wanted.
I have modified the code slightly to suit my use and to allow for additional controls on the switchboard, see attachemnt for example and code below.
Option Compare Database
Private Sub Form_Load()
On Error Resume Next
With Me
.lblEmployee.ForeColor = vbWhite
.lblImport.ForeColor = vbWhite
.lblReports.ForeColor = vbWhite
.lblSecurity.ForeColor = vbWhite
End With
End Sub
Private Sub lblEmployee_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
On Error Resume Next
With Me
.lblEmployee.ForeColor = vbBlue
.lblImport.ForeColor = vbWhite
.lblReports.ForeColor = vbWhite
.lblSecurity.ForeColor = vbWhite
End With
End Sub
Private Sub Detail_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
On Error Resume Next
With Me
.lblEmployee.ForeColor = vbWhite
.lblImport.ForeColor = vbWhite
.lblReports.ForeColor = vbWhite
.lblSecurity.ForeColor = vbWhite
End With
End Sub
Private Sub lblEmpty1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
On Error Resume Next
With Me
.lblImport.ForeColor = vbWhite
.lblEmployee.ForeColor = vbWhite
.lblReports.ForeColor = vbWhite
.lblSecurity.ForeColor = vbWhite
End With
End Sub
Private Sub lblEmpty2_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
On Error Resume Next
With Me
.lblImport.ForeColor = vbWhite
.lblEmployee.ForeColor = vbWhite
.lblReports.ForeColor = vbWhite
.lblSecurity.ForeColor = vbWhite
End With
End Sub
Private Sub lblEmpty3_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
On Error Resume Next
With Me
.lblImport.ForeColor = vbWhite
.lblEmployee.ForeColor = vbWhite
.lblReports.ForeColor = vbWhite
.lblSecurity.ForeColor = vbWhite
End With
End Sub
Private Sub lblImport_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
On Error Resume Next
With Me
.lblImport.ForeColor = vbBlue
.lblEmployee.ForeColor = vbWhite
.lblReports.ForeColor = vbWhite
.lblSecurity.ForeColor = vbWhite
End With
End Sub
Private Sub lblReports_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
On Error Resume Next
With Me
.lblReports.ForeColor = vbBlue
.lblImport.ForeColor = vbWhite
.lblEmployee.ForeColor = vbWhite
.lblSecurity.ForeColor = vbWhite
End With
End Sub
Private Sub lblSecurity_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
On Error Resume Next
With Me
.lblSecurity.ForeColor = vbBlue
.lblImport.ForeColor = vbWhite
.lblReports.ForeColor = vbWhite
.lblEmployee.ForeColor = vbWhite
End With
End Sub
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.