Results 1 to 4 of 4
  1. #1
    julie is offline Novice
    Windows XP Access 2007
    Join Date
    Feb 2010
    Posts
    2

    Query to add a specific number of an option from a combo box

    I need a query to apply to a form that will allow a user to select an item from a combo box, then type in a number to generate that many records in the table. For example. We track each person by a source, internet hits come in all day and it is too hard to hand input 75 records for a website hit. Importing from excel is an option but I want to make it easy for the user with a form. Please let me know if I am not clear.

  2. #2
    llkhoutx is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Jan 2010
    Location
    Houston, Texas USA
    Posts
    373
    On the AfterUpdate event of the combobox, if Not Null run DAO or ADO code to add the requisite number of records.

  3. #3
    julie is offline Novice
    Windows XP Access 2007
    Join Date
    Feb 2010
    Posts
    2
    Can you type what Im exactly supposed to input in the After Event Expression Build Field? Im new to Access and just trying to make a good database for my users.

  4. #4
    llkhoutx is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Jan 2010
    Location
    Houston, Texas USA
    Posts
    373
    Assume control cboNRecs on your form holds the (integer) number of records. On the cboNRecs AfterUpdate insert the following code

    Code:
    private sub cboiNRecs_AfterUpdate()
    dim db as database
    dim rs 
    as recordset
    dim i 
    as integer
    if forms!YourformName!cboNRecs 1 then goto Exit_Exit
    set db
    =currentdb
    set rs
    =db.openrecordset("YourTableName",dbopendynaset)
    for 
    1 to forms!YourformName!cboNRecs
      rs
    .addnew
      rs
    .update
    next
    rs
    .close
    db
    .close
    set rs
    =nothing
    set db
    =nothing
    Exit_Exit
    :
    exit 
    sub 

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

Similar Threads

  1. Query Out Specific Text
    By ysabella in forum Queries
    Replies: 1
    Last Post: 11-19-2015, 03:53 AM
  2. Passing specific Combobox info to a query
    By pwdpwd in forum Queries
    Replies: 1
    Last Post: 02-09-2010, 12:53 PM
  3. Replies: 1
    Last Post: 11-10-2009, 03:20 PM
  4. no option to import xls file or option all files
    By captgnvr in forum Import/Export Data
    Replies: 3
    Last Post: 09-22-2009, 10:19 AM
  5. Auto Number in Query
    By Alex Motilal in forum Programming
    Replies: 1
    Last Post: 09-21-2009, 07:17 AM

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