C_Monster221
New member
- Local time
- Today, 08:06
- Joined
- Jan 23, 2009
- Messages
- 8
Hi,
This is my problem I am simply trying to make a (i guess) a link to corresponding data from a report. I need to be able to click on say a peron's name listed on the report and have that peron's info open up in the corresponding form. I have a made a macro that does this yet it opens the same file regardless what name I click. I have converted this macro to vb for better help and understanding of what I am doing wrong.
Function Linking_Macro()
On Error GoTo Linking_Macro_Err
With CodeContextObject
On Error Resume Next
If (.Form.Dirty) Then
DoCmd.RunCommand acCmdSaveRecord
Exit Function
End If
On Error GoTo 0
DoCmd.OpenForm "frmconsumers", acNormal, "", ['[MEDRECNO]] = "'" & Nz([MEDRECNO], 0), , acDialog
If (Not IsNull(.MEDRECNO)) Then
TempVars.Add "CurrentID", "[MEDRECNO]"
End If
If (IsNull(.MEDRECNO)) Then
TempVars.Add "CurrentID", "Nz(DMax('[MEDRECNO]',[FRMCONSUMERS]),0)"
End If
DoCmd.Requery ""
DoCmd.SearchForRecord , "", acFirst, [[MEDRECNO]] = "'" & TempVars!CurrentID
TempVars.Remove "CurrentID"
End With
Linking_Macro_Exit:
Exit Function
Linking_Macro_Err:
MsgBox Error$
Resume Linking_Macro_Exit
End Function
This function opens the form but displays no info in it. Please note that all data in use is text.
This is my problem I am simply trying to make a (i guess) a link to corresponding data from a report. I need to be able to click on say a peron's name listed on the report and have that peron's info open up in the corresponding form. I have a made a macro that does this yet it opens the same file regardless what name I click. I have converted this macro to vb for better help and understanding of what I am doing wrong.
Function Linking_Macro()
On Error GoTo Linking_Macro_Err
With CodeContextObject
On Error Resume Next
If (.Form.Dirty) Then
DoCmd.RunCommand acCmdSaveRecord
Exit Function
End If
On Error GoTo 0
DoCmd.OpenForm "frmconsumers", acNormal, "", ['[MEDRECNO]] = "'" & Nz([MEDRECNO], 0), , acDialog
If (Not IsNull(.MEDRECNO)) Then
TempVars.Add "CurrentID", "[MEDRECNO]"
End If
If (IsNull(.MEDRECNO)) Then
TempVars.Add "CurrentID", "Nz(DMax('[MEDRECNO]',[FRMCONSUMERS]),0)"
End If
DoCmd.Requery ""
DoCmd.SearchForRecord , "", acFirst, [[MEDRECNO]] = "'" & TempVars!CurrentID
TempVars.Remove "CurrentID"
End With
Linking_Macro_Exit:
Exit Function
Linking_Macro_Err:
MsgBox Error$
Resume Linking_Macro_Exit
End Function
This function opens the form but displays no info in it. Please note that all data in use is text.