Results 1 to 10 of 10
  1. #1
    AndycompanyZ is offline Advanced Beginner
    Windows Vista Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    80

    Msgbox with data in

    I have been trying to work out a way of doing the following:


    I have a subform that is populated with dlegates who are scheduled onto the event of the mainform (frmEvent). This works correctly and shows details about the delegates. What I need to do is that if the delegateID is the same as the SubTeamHeadDelID a messagebox to popup showing the mobilenumber of the SubTeamParentID.
    I have the following code so far:

    Code:
     
    If Me.SubTeamHeadDelID = Me.DelegateID Then
    Dim strID As String
    strID = Nz(DLookup("DelegateMobileNumber", "tblDelegate", "DelegateID =" & Me.SubteamParentID), "0")
    If strID = "0" Then
    MsgBox "You don't need to contact anyone or whatever is needed"
    Else
    MsgBox "Please contact this SubTeamLeader or whatever " & strID, vbOKOnly
    End If
    But gives me severe errors that "A problem occured while Access was communicating with the OLE sever or an ActiveX control"

    Can anyone shed any light

    Ignore a lot of this as i realised my logic isn't right.

  2. #2
    AndycompanyZ is offline Advanced Beginner
    Windows Vista Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    80
    I have now changed it to:

    Code:
     
    If Me.SubTeamHeadDelID = Me.DelegateID Then
    Dim strID As String
    Dim strID2 As String
     
    strID = Nz(DLookup("SubTeamParentID", "tblSubTeam", "DelegateID =" & Me.SubteamParentID), "0")
    strID2 = (DLookup("DelegateMobileNumber", "tblDelegate", "ID =" & Me.SubteamParentID))
    If strID = "0" Then
    MsgBox "You don't need to contact anyone or whatever is needed"
    Else
    MsgBox "Please contact this SubTeamLeader or whatever " & strID2, vbOKOnly
    End If
    But still giving me same error and it prvents me from running the code with breakpoints to errorcheck because of the message

  3. #3
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    In which form are you running this code (MainForm/SubForm) and in which event?

  4. #4
    AndycompanyZ is offline Advanced Beginner
    Windows Vista Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    80
    At the moment I have it as a button on the subform just for testing purposes but I've tried in various other places on the subform like on load and on focus for fields. I've tried rebooting and reloading access but getting same errors I have changed it to;
    Code:
     
    If Me!SubTeamHeadDelID = Me!DelegateID Then
    Dim strID As String
    Dim strID2 As String
     
     strID = Nz(DLookup("SubTeamParentID", "tblSubTeam", "SubTeam =" & Me!SubTeam), "0")
     
     If strID = "0" Then
     MsgBox "You don't need to contact anyone or whatever is needed"
     Else
     strID2 = (DLookup("DelegateMobileNumber", "tblDelegate", "ID =" & Me!SubteamParentID))
     MsgBox "Please contact this SubTeamLeader  & strID2", vbOKOnly
     End If
    But getting same error

  5. #5
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    I take it these two controls Me!SubTeamHeadDelID and Me!DelegateID are on your SubForm?

  6. #6
    AndycompanyZ is offline Advanced Beginner
    Windows Vista Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    80
    Yes they are

  7. #7
    AndycompanyZ is offline Advanced Beginner
    Windows Vista Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    80
    Aha I've got somewhere now I built a new database and imported evrything into this and now it works but gives me a normal bug that I can see and should be able to work with

  8. #8
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Great! Let us know if you need any further assistance.

  9. #9
    AndycompanyZ is offline Advanced Beginner
    Windows Vista Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    80
    Update on this problem I now have:


    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
    But this tells me I have a missing operator in the highlighted line. The debug.print show the correct subteam but only one shouldn't there be 2 one from the form and one from the table. the subteam is a text field on the tbale do i need to put anything to show this in the code line.

  10. #10
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Why didn't you use: Debug.Print Me!SubTeam
    ...just as you did in the Domain function.
    FYI: *NOTHING* is ever = to Null as Null by definition is undefined. That is what the IsNull() function was created for.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. MsgBox to update field. What's next?
    By JeffG3209 in forum Programming
    Replies: 3
    Last Post: 05-05-2011, 12:51 AM
  2. MsgBox Placement
    By tpcervelo in forum Programming
    Replies: 2
    Last Post: 12-27-2010, 07:36 AM
  3. Custom MsgBox
    By roccoIT in forum Programming
    Replies: 3
    Last Post: 07-06-2010, 10:43 AM
  4. Yes No Cancel MsgBox
    By Rick West in forum Forms
    Replies: 5
    Last Post: 04-14-2010, 08:57 AM
  5. Alterations to MsgBox command
    By Robert M in forum Programming
    Replies: 4
    Last Post: 06-30-2009, 02:14 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums