Results 1 to 4 of 4
  1. #1
    Join Date
    May 2011

    Unanswered: Using numeric variable from Text Box to Repeat Text based on entered Variable


    My name is Ron and I'm was just introduced to DB Forums so it is with great honor that I join your community.

    I'm relatively new to Microsoft Access and I'm trying to learn the code. I'm a pharmacist and I wanted to create a program within Microsoft Access that asked for a numeric variable within a Text Box in one form. Then create a second form and in which it will repeat:

    [Label] [Text Box] [Label] [Text Box]

    based on that number entered in the first form.

    For example:

    In my program currently. It asks on Form1:

    [Label: "How many times are they tapering?"] [Text Box]

    Then, I have a second button that opens a new form, Form2, and based on the number entered, for example 3, it would repeat the following phrase, three times.

    "Take" [Text Box] "Tablet(s) by mouth" [Text Box]"."

    "Take" [Text Box] "Tablet(s) by mouth" [Text Box]"."

    "Take" [Text Box] "Tablet(s) by mouth" [Text Box]"."

    Is this possible? Thank you for your time. I am very grateful.

  2. #2
    Join Date
    Feb 2004
    New Zealand
    Provided Answers: 8
    I would use a continuous form

    Your way can be done with a lot of coding
    Ie make the label , text box then you have place on the with more coding
    hope this help

    See clear as mud

    StePhan McKillen
    the aim is store once, not store multiple times
    Remember... Optimize 'til you die!
    Progaming environment:
    Access based on my own environment: DAO3.6/A97/A2000/A2003/A2007/A2010
    VB based on my own environment: vb6 sp5
    ASP based on my own environment: 5.6
    VB-NET based on my own environment started 2007
    SQL-2005 based on my own environment started 2008

  3. #3
    Join Date
    May 2011
    Would a continuous form still require VB coding to get the results I need? If so, I'm still confused about how to go about the coding? I couldn't find any help at Microsoft support about this type of question either.

  4. #4
    Join Date
    Mar 2009
    Provided Answers: 14
    There is no simple answer to you question, mainly because Access does not permit the creation of controls (TextBoxes and Labels in your case) dynamically, i.e. using VBA code, when a form is open is View mode. To create a control on a form this form must be open in Design mode. You can then use some VBA code to create a control on the form, assign values to its properties and eventually delete it. This requires an in-depth knowledge of both VBA and the Access Object Model. It's feasible but it's not a solution I would recommend.

    Myle's solution, using a continuous form could be a good one. You'll need to use a dummy table containing as many rows as you want repetitions on the form. You would bound the form to the dummy table, use a bound textbox that you could keep hidden (Visible property set to False) and add controls (Labels, TextBoxes) that would be repeated in the continuous form. As the repeated controls would all have the same name, you'll need to use the contents of the bound (hidden) control to determine the precise set of controls that constitutes a line.

    If the number of lines (set of controls) is limited and you know the limit (i.e. the max. possible number of lines) you could also create all the necessary controls on the form and hide/unhide them according to the number of lines you want to display at a given time.
    Have a nice day!

Posting Permissions

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