Results 1 to 6 of 6

Thread: Expression in subform

  1. #1
    Join Date
    Dec 2008
    Posts
    37

    Question Expression in subform

    Hi

    I have a universal subform which is used in a number of different reports. All of these reports have the control [Country Code] that is referenced. Is it possible to create a global reference to replace the one I am using that only works for the specific report mentioned:

    =[Reports]![Prospect Listing - All Clients by Class]![Country Code]

    All suggestions very welcome?

    Regards

    Tony Randell

  2. #2
    Join Date
    Dec 2008
    Posts
    37

    Expression in SubReport

    Apologies - This should read subreport not subform.

  3. #3
    Join Date
    May 2006
    Posts
    407
    In the module for the subreport, place this code:
    Code:
    Function RtnCountryCode()
      RtnDesc = Me.Parent.[Country Code]
    End Function
    Then refer to this function wherever you need the value from the parent report. ie: =RtnCountyCode()

  4. #4
    Join Date
    Dec 2008
    Posts
    37

    Expression in subform

    Thanks for that - it works well. Sorry for the delay in responding.

    I have actually used it in a subrtn that will call Skype if one doubleclicks on a phone no in an Access form. The subrtn formats the no and passes it to Skype to dial and is working well now.

  5. #5
    Join Date
    May 2006
    Posts
    407
    Would be nice if you posted your code so that someone else that might want this functionality would not have to reinvent the "wheel."

    I'm glad this worked for you.

  6. #6
    Join Date
    Dec 2008
    Posts
    37

    Skype calls in Access

    The code I used was based on that given at http://www.datahousesoftware.com/access/skype.htm.

    I replaced forms specific code with me.[ctlname] and mine looks like:

    Private Sub Telephone_DblClick(Cancel As Integer)
    On Error GoTo HandleErr

    CallToNumber ([Telephone])

    ExitHere:
    Exit Sub

    HandleErr:
    MsgBox "Invalid Skype Phone No"

    End Sub


    Public Function CallToNumber(strNumber As String)
    On Error GoTo HandleErr

    Dim strPhoneNumberCleaned, strFirstDigit, strCall, strCountryCode, stLink As String

    strCountryCode = Me.[DialCode]
    strPhoneNumberCleaned = Replace((Replace((Replace((Replace(strNumber, " ", "")), "-", "")), "(", "")), ")", "")
    strFirstDigit = Left(strPhoneNumberCleaned, 1)

    strCall = strCountryCode & strPhoneNumberCleaned

    If strFirstDigit = "+" Then
    strCall = strPhoneNumberCleaned
    End If

    If strFirstDigit = "0" Then
    strCall = strCountryCode & Right(strPhoneNumberCleaned, (Len(strPhoneNumberCleaned) - 1))
    End If


    stLink = "callto://" & strCall
    Application.FollowHyperlink stLink


    ExitHere:
    Exit Function

    HandleErr:
    MsgBox "Skype Dialling Error"


    End Function


    If this was used in a subform I replaced me.[ctlname] with me.parent.[ctlname]

    Hope this helps.

    Rgds

    Tony Randell

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •