mcdhappy80
Registered User.
- Local time
- Today, 13:54
- Joined
- Jun 22, 2009
- Messages
- 347
This code is a converted macro which opens a form when You click on a hyperlik in datasheet table:
If someone could explain code line by line.
Thank You.
Code:
Option Compare Database
'------------------------------------------------------------
' HyperlinkOpen
'
'------------------------------------------------------------
Function HyperlinkOpen()
On Error GoTo HyperlinkOpen_Err
With CodeContextObject
On Error Resume Next
If (.Form.Dirty) Then
DoCmd.RunCommand acCmdSaveRecord
End If
If (.MacroError.Number <> 0) Then
Beep
MsgBox .MacroError.Description, vbOKOnly, ""
Exit Function
End If
On Error GoTo 0
DoCmd.OpenForm "Expense Report Details", acNormal, "", "[ID]=" & Nz(.ID, 0), , acDialog
If (Not IsNull(.ID)) Then
TempVars.Add "CurrentID", "[ID]"
End If
If (IsNull(.ID)) Then
TempVars.Add "CurrentID", "Nz(DMax(""[ID]"",[Form].[RecordSource]),0)"
End If
DoCmd.Requery ""
DoCmd.SearchForRecord , "", acFirst, "[ID]=" & TempVars!CurrentID
TempVars.Remove "CurrentID"
End With
HyperlinkOpen_Exit:
Exit Function
HyperlinkOpen_Err:
MsgBox Error$
Resume HyperlinkOpen_Exit
End Function
Thank You.