Results 1 to 3 of 3
  1. #1
    mcucino is offline Advanced Beginner
    Windows 8 Access 2016
    Join Date
    Jul 2017
    Location
    Providence, RI
    Posts
    74

    Using form and field names as variables

    Hello All, I am hoping this is an easy question but I tried some examples off google and didn't have much luck. I want to have multiple forms point to one form called "InsertItemF". Let's call one the these forms SourceFormF. InsertItemF populates a listbox from a variety of tables based on specific parameters. It concatenates a string that is inserted into the SourceFormF.



    The code that opens InsertItemF from SourceFormF also populates two fields, SourceForm and SourceField on InsertItemF (these are referenced in the code below)

    Code:
    Private Sub InsertItem()
    Dim SrcFrm As Form
    Dim SrcFld As String
    
    
        Set SrcFrm = Forms(Me.SourceForm)
        SrcFld = Me.SourceField
        
        Forms!SrcFrm!SrcFld = " nz(Dsum('[MMYYYY " & Me.CalcTypeCombo.Column(1) & "]', '[" & Me.TableCombo & "]', 'ID = " & Me.LineItemList.Column(0) & "'),0)"
        
    End Sub
    And here's a visual (red circle is the button on SourceF that opens InsertItemF, blue circle is the form/field names that were inserted by the red circled button. In this example it should be SourceF instead of Iif):
    Click image for larger version. 

Name:	InsertItemF.JPG 
Views:	26 
Size:	131.4 KB 
ID:	36214

  2. #2
    GinaWhipp's Avatar
    GinaWhipp is offline Competent Performer
    Windows 7 64bit Access 2013 32bit
    Join Date
    Jul 2011
    Location
    Ohio, USA
    Posts
    377
    Hmm, not sure I understand exactly what you are trying to do. However, it occurs to me you should be pointing to the Control Name which should pull the value of that Control.

  3. #3
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    I've read this post a half dozen times, and like Gina, and probably the other 150+ members who have read it and not responded...I have no real idea of what you're trying to do, here!

    Statements such as

    ...Using form and field names as variables...

    ...I want to have multiple forms point to one form...
    simply makes no sense.

    I suspect you'd be better off to tell us, in plain language, exactly what you're trying t to accomplish, leaving out technical terms.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

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

Similar Threads

  1. Replies: 7
    Last Post: 03-21-2018, 04:58 AM
  2. How to mention field names along with variables
    By pardhu81 in forum Programming
    Replies: 2
    Last Post: 05-09-2017, 09:03 AM
  3. Replies: 5
    Last Post: 03-31-2015, 12:03 PM
  4. Need Input on Form Design - Dynamic Field Names?
    By Madmartigan in forum Forms
    Replies: 8
    Last Post: 03-07-2014, 01:07 PM
  5. Replies: 5
    Last Post: 12-22-2012, 01:36 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