Advertisement

07.16.2008 at 10:49AM PDT, ID: 23570603
[x]
Attachment Details

Add x records to table

Asked by BobRosas in Access Forms, SQL Query Syntax

Tags: VBA, Microsoft Access

I have a form where the user enters multiple records and since some fields in each record often repeat they asked for a duplicate button.  That part works.  However, now they'd like it to automatically "Duplicate" based on square feet.  Each 100 feet requries a record.  So for 101 sqft I need two records.
1.  They are required to fill in the first record
2.  They enter the square feet
3.  After update on Sq ft I created code that calculates the number of records I need to add.
   If they entered 101 feet I need to add one more record for a total of 2.

Is there a way to call the Duplicate code (from a subform) x times?
Is there a better way to do this?

Here's my Duplicate code

Private Sub cmdDup_Click()
On Error GoTo Err_cmdDup_Click

    strSpotPaintProduct = cboSpotPaintProduct            
    strSpotCoat = cboSpotCoat
    strSpotItemDesc = cboSpotItemDesc
    strSpecifiedDFT = txtSpecifiedDFT
    DoCmd.GoToRecord , , acNewRec                          
    cboSpotPaintProduct = strSpotPaintProduct
    cboSpotCoat = strSpotCoat
    cboSpotItemDesc = strSpotItemDesc
    txtSpecifiedDFT = strSpecifiedDFT
    DoCmd.GoToControl "txtA1"
   
Exit_ccmdDup_Click:
    Exit Sub

Err_cmdDup_Click:
     MsgBox Err.Description
End Sub
 Start Free Trial
[+][-]07.16.2008 at 12:22PM PDT, ID: 22019212

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Access Forms, SQL Query Syntax
Tags: VBA, Microsoft Access
Sign Up Now!
Solution Provided By: DanielWilson
Participating Experts: 2
Solution Grade: A
 
 
[+][-]07.16.2008 at 02:27PM PDT, ID: 22020362

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.16.2008 at 06:11PM PDT, ID: 22021585

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]07.17.2008 at 09:08AM PDT, ID: 22026996

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628