I have posted this before on another board but I'm stuck with even thinking about how to go about this. I need to create a query so I can build a datasheet off of it. The query will look at a number of tables and select all those delegates who are scheduled onto an event. I then need to do the following which I've written in VBA (and this is pseudocode of what i want to do) but need to translate this into a query somehow:
If the delegateID in a subteam is = to the SubTeamHeadDelID then
Show the subTeamParentID and details of this person (who has their details in the delegate details tabel (everyone is in this table)) but if there is no SubTeamParentID in the table then I don't need to do anything.
I envisage the datasheet as being a list of delegates with columns showing their details and the phonenumber of the person(SubTeamParent or SubTeamDelID) to contact. It seems to me insurmountable in a query. I have the following in VBA:
which I had hoped to use but the syntax is wrong anyway but I need the same result in a query. I've been reading as much as i can on queries but nothing seems what i want to do. I think it maybe a subquery or 2 one to show who is a delegate and a subteamhead and then one to show who is a SubTeamParent and then include that in my query somehow. I'm a bit confused to say the least.Code:If Me!SubTeamHeadDelID = Me!DelegateID Then Dim strID As String Dim strID2 As String Debug.Print SubTeam strID = DLookup("SubTeamParentID", "tblSubTeam", "SubTeam = " & Me!SubTeam) If strID = Null Then MsgBox "You don't need to contact anyone or whatever is needed" Else strID2 = DLookup("DelegateMobileNumber", "tblDelegate", "ID =" & strID) MsgBox "Please contact this SubTeamLeader & strID2", vbOKOnly End If End If