TheMadRonin
New member
- Local time
- Today, 14:18
- Joined
- Feb 21, 2008
- Messages
- 6
Hi folks!
I will confess right here up front that when it comes to VBA code I am a total novice and still have a great deal to learn so I am appealing to the good nature and superior expertise of you wonderful people to help me achieve my goal!
Please note I have searched high and low for an answer here on the boards but cannot seem to find anything that helps out!
Ok with that in mind, what I am attempting to do here is this... when the user clicks a button on the form, the account numbers of all linked accounts will pop up in a nice friendly msgbox, for example:
AcNo LinkNo
1234 1
2345 1
3456 1
4567
5789
So when the user looking at account 1234 clicks the button the message box will return a brief intro and the the values 2345 & 3456.
The code in itself works exactly as I want it to except for the fact that due to using DLOOKUPthe only value it will return is the first value in the link set, ie 1234 regardles of which account is being viewed.
So would any of you delightful people know where I am going wrong (apart from with using DLOOKUP of course) and what I can do to remedy it?
Many thanks is advance,
TheMadRonin.
I will confess right here up front that when it comes to VBA code I am a total novice and still have a great deal to learn so I am appealing to the good nature and superior expertise of you wonderful people to help me achieve my goal!
Please note I have searched high and low for an answer here on the boards but cannot seem to find anything that helps out!
Ok with that in mind, what I am attempting to do here is this... when the user clicks a button on the form, the account numbers of all linked accounts will pop up in a nice friendly msgbox, for example:
AcNo LinkNo
1234 1
2345 1
3456 1
4567
5789
So when the user looking at account 1234 clicks the button the message box will return a brief intro and the the values 2345 & 3456.
The code in itself works exactly as I want it to except for the fact that due to using DLOOKUPthe only value it will return is the first value in the link set, ie 1234 regardles of which account is being viewed.
So would any of you delightful people know where I am going wrong (apart from with using DLOOKUP of course) and what I can do to remedy it?

Many thanks is advance,
TheMadRonin.
Code:
[FONT=Courier New]Private Sub LinkFilter_Click()[/FONT]
[FONT=Courier New] Dim varX As Variant[/FONT]
[FONT=Courier New] If IsNull([LinkNumber]) Then[/FONT]
[FONT=Courier New] MsgBox "This trust is not linked to any other trusts."[/FONT]
[FONT=Courier New] Else[/FONT]
[FONT=Courier New] varX = DLookup([IMSNumber], "tblregister20082009", [LinkNumber] = Me!LinkNumber)[/FONT]
[FONT=Courier New] If MsgBox("This trust is linked to the following trusts:" & vbCrLf & vbCrLf & varX & vbCrLf & vbCrLf & "Do you wish to filter the register to work on these entries only?", vbQuestion + vbYesNo + vbDefaultButton2, "View Linked Trusts") = vbYes Then[/FONT]
[FONT=Courier New] Dim stDocName As String[/FONT]
[FONT=Courier New] Dim stLinkCriteria As String[/FONT]
[FONT=Courier New] stDocName = "frmReturns20082009"[/FONT]
[FONT=Courier New] stLinkCriteria = "[LinkNumber]=" & Me![LinkNumber][/FONT]
[FONT=Courier New] DoCmd.OpenForm stDocName, , , stLinkCriteria[/FONT]
[FONT=Courier New] Me!LinkFilter.Visible = False[/FONT]
[FONT=Courier New] Me!ResetFilter.Visible = True[/FONT]
[FONT=Courier New] Else[/FONT]
[FONT=Courier New] End[/FONT]
[FONT=Courier New] End If[/FONT]
[FONT=Courier New] End If[/FONT]
[FONT=Courier New]End Sub[/FONT]