Use Input Value in Form as a Field Name

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • byte5
    New Member
    • Nov 2012
    • 2

    Use Input Value in Form as a Field Name

    So, Here's the situation.

    I need to create a report for a particular name between the given dates.
    The table consists of fields like survey name, date, name1, name2....name5 (name1-5 are boolean fields, which basically tell if that user has taken the survey)

    So, I create a form and take inputs for begin date, end date and name. I generate a macro which goes like
    Code:
    [table].[date]>=[form].[begindate] And [table].[date]<=[form].[enddate]
    .

    Now suppose the user gives name1 as the input, how do I get it as an expression?
  • zmbd
    Recognized Expert Moderator Expert
    • Mar 2012
    • 5501

    #2
    First it sounds like your database is not normalized.
    Database Normalization and Table Structures.

    [[Well... that sounded harsh... sorry... the twins have just gotten thru the potty training stage and are now attempting to not have Mommy/Daddy come and help. This results in a mess when the toilet is flushed... thank God for wet/dry shop vac and Bleach!]]

    I still stand by the normalization comment

    By way of applogies allow me to provide some insite to how I would design the database::

    From OP:
    At minimum (and I can see in my mind's eye this growing):
    You should have a table with the people information
    You should have a table with the survey information
    You should have a table that relates these two tables

    (table structure)
    Name: tbl_people
    [people_pk] autonumber primary key
    [people_title] text(4)
    [people_firstnam e] text(20)
    [people_lastname] text(20)
    [people_age] numeric(integer )
    (add other fields as needed)

    Name: tbl_survey
    [survey_pk] autonumber primary key
    [survey_name] text(20)
    [survey_topic] text(100)
    (add other fields as needed)

    Name: tbl_taken
    [taken_pk] autonumber primary key

    [taken_FK_people] numeric(long) foreign key from tbl_people (1:m)

    [taken_FK_survey] numeric(long) foreign key from tbl_survey (1:m)

    [taken_startdate] Date/time

    [taken_enddate] date/time

    (data entry)
    (forms)
    Form to handle data entry for people information
    Form to handle data entry for survey information

    (** and for the magic **)
    Form to handle the taken information and I'l give you some detail:
    Form needs at least one combobox for the people.
    control source is set to [taken_FK_people]
    record source is against tbl_people subquery to show just the PK and First and Last Names. The PK value is hidden in the display however, it is the value of the combobox

    Form needs at least one combobox for the survey.
    control source is set to [taken_FK_survey]
    record source is against tbl_survey subquery to show just the PK and survey Names. The PK value is hidden in the display however, it is the value of the combobox

    Form needs at least one textbox for the start date.

    Form needs at least one textbox for the end date.

    This will work without any VBA coding.

    What you do is create a new record in tbl_taken for every survey taken by the person for example if Person Mr. Alpha Zulu takes three tests then there will be three records showing Mr. AZ and each one showing the related test.

    Now... We're not a code writing or homework service; however, if you will show me/us your current work then we can proceed with the informing, the clarifying, and the correcting.
    Last edited by zmbd; Nov 17 '12, 12:02 AM. Reason: [Z{returned from the twins trying to float the bathroom away again... gota love'um :) }]

    Comment

    • byte5
      New Member
      • Nov 2012
      • 2

      #3
      Thank you so much. This makes a lot of sense!

      Comment

      • zmbd
        Recognized Expert Moderator Expert
        • Mar 2012
        • 5501

        #4
        opps... forgot to mention that the form for the tbl_taken would be bound as would the controls to the tbl_taken table
        (0-0)

        Comment

        Working...