Results 1 to 6 of 6
  1. #1
    webfactoryuk is offline Novice
    Windows Vista Access 2007
    Join Date
    Apr 2011
    Posts
    25

    A form that builds a table with a certain amount of records


    I was wondering if it was possible (or if anyone has any better solutions) to create a form with a single text field that I can enter a number in say 32.

    The form would then create a table with 32 records with the numbers 1 - 32 in.

    Basically I want the user of my inspection system to be able to enter the number of 'locations' to be inspected before they start. Just so they dont lose count half way round.

    I was thinking if I could make a form that creates a table and then have a combo box read from that table?

    Unless I have missed a better way to do it.

    Thanks in advance!

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2007
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Here is one way to try.
    Private Sub textboxname_AfterUpdate()
    DoCmd.SetWarnings False
    DoCmd.RunSQL "CREATE TABLE ..."
    For i = 1 to 32
    DoCmd.RunSQL "INSERT INTO tablename (fieldname) VALUES (" & i & ")"
    Next
    DoCmd.SetWarnings True
    Me.Requery
    End Sub

    Check this article about using the CREATE TABLE sql http://www.w3schools.com/sql/sql_create_table.asp

    What do you mean by 'have a combobox read from that table'? How does that help with data entry?

  3. #3
    webfactoryuk is offline Novice
    Windows Vista Access 2007
    Join Date
    Apr 2011
    Posts
    25
    That looks good thanks!

    It helps because the user doesnt have to remember whats next in the report. The combo box will list the next step (location) in the report for them.

    Cant think of any other way to do it?

    Ideally I guess there wouldnt even be a combo box, each record would just be assigned a location and they would click next to move on or something but not sure if you have seen my other threads? Im already out of my depth lol

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2007
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Right, I see no purpose for the combobox. The records have no data so what would the combobox show?

    How would each record be assigned location info programmatically? Isn't that data user has to enter?

    The form could be set to move into next record after enter value in last field. Need to make sure the TabOrder property of controls is numbered correctly.

    Not sure if I have seen other threads, will do a search.

  5. #5
    Mclaren is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Feb 2010
    Location
    Johannesburg
    Posts
    164
    This might work for me too. I need to ensure when a new record is created in the primary table, the linked table has exactly 14 records for each record in the primary table.
    The only difference is for each new record in the primary table, i have to add records to the linked table.

    Gonna go fiddle with the code.

    Thanks guys

  6. #6
    Mclaren is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Feb 2010
    Location
    Johannesburg
    Posts
    164

    Update

    Worked a treat. Just removed the create table section.

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

Similar Threads

  1. More records in table than form
    By GraemeG in forum Access
    Replies: 2
    Last Post: 03-11-2011, 02:44 PM
  2. Replies: 3
    Last Post: 01-24-2011, 12:04 PM
  3. Add & Pull Records from Table via Form
    By sujitshukla in forum Programming
    Replies: 1
    Last Post: 08-02-2010, 05:51 PM
  4. Replies: 0
    Last Post: 02-24-2010, 12:56 AM
  5. Replies: 3
    Last Post: 06-01-2009, 01:41 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