Assign Variable Main and Subform name

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • phill86
    New Member
    • Mar 2008
    • 121

    Assign Variable Main and Subform name

    Hi,

    I want to be able to assign a variable with a subform name the following code allows me to get the main form name but I also need the subform within the form


    Code:
    Dim strFormName As String
    strFormName = Me.name
    Also i need to be able to combine the value of two fields from a form so i will end up with a variable that contains monday08:00

    Code:
    Monday = [Forms]![FrmCalendarMain].[SfrCalS104]![TxtMon]
       
    txtMon0800 = [Forms]![FrmCalendarMain].[SfrCalS104]![Txt08:00]
    Any help is much appreciated

    Cheers Phill
  • ChipR
    Recognized Expert Top Contributor
    • Jul 2008
    • 1289

    #2
    Code:
    Dim strSubFormName As String
    strSubFormName = Me.mySubformControl.Form.Name
    Append strings with the & character, but if you are in code on the main form and want to access the value in a text box on a subform (assuming SfrCalS104 is a subform):
    Code:
    Dim strMonday0800 As String
    strMonday0800 = Me.SfrCalS104.Form!txtMon & " " & Me.SfrCalS104.Form!txt0800
    I would advise against using a colon in a name. Here is the guide I use to determine how to refer to items on other forms and subforms: Refer to Form and Subform properties and controls. Good luck!

    Comment

    • phill86
      New Member
      • Mar 2008
      • 121

      #3
      Hi Chip R

      Thanks for that

      I need to know what form and subform is currently loaded so it could be one of several different forms

      Apologies if I did not make myself clear

      Regards Phill

      Comment

      Working...