Generate new records based on value typed in form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm trying to generate a new record based on a value typed in a form. For example, I am purchasing 10 television sets. Once I type in 10 in the Form, I would like ten new records to appear in a serial number table. The serial number table would have an autonumber function and include the brand of the television set and customer name.
 
Hi,

Here's a piece of sample code that should give you some ideas:

Function funcAppendToTable(strNumberOfTimes As Integer)

Dim i as Integer
For i = 1 To strNumberOfTimes
CurrentDb.Execute "INSERT INTO Table1 ( Field1, Field2, Field3 )
SELECT 'Z', 2, 'Y';"
Next i

End Function


The above function runs the INSERT INTO sql statement x number of times (in
a Loop) appending as you see the same values. Of course you could change
the values in the Loop if needed.


I hope this helps! If you have additional questions on this topic, please
respond back to this posting.


Regards,

Eric Butts
Microsoft Access Support

"Microsoft Security Announcement: Have you installed the patch for
Microsoft Security Bulletin MS03-026? If not Microsoft strongly advises
you to review the information at the following link regarding Microsoft
Security Bulletin MS03-026
<http://www.microsoft.com/security/security_bulletins/ms03-026.asp> and/or
to visit Windows Update at <http://windowsupdate.microsoft.com/> to install
the patch. Running the SCAN program from the Windows Update site will help
to insure you are current with all security patches, not just MS03-026."


--------------------
| Thread-Topic: Generate new records based on value typed in form
| thread-index: AcP6HpGK2udnn9+wRJuJ4NKMAkddgw==
| X-Tomcat-NG: microsoft.public.access.forms
| From: "=?Utf-8?B?TmV3QWNjZXNzUXVlc3Rpb24=?="
<[email protected]>
| Subject: Generate new records based on value typed in form
| Date: Mon, 23 Feb 2004 07:06:09 -0800
| Lines: 1
| Message-ID: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.public.access.forms
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.access.forms:256505
| NNTP-Posting-Host: tk2msftcmty1.phx.gbl 10.40.1.180
| X-Tomcat-NG: microsoft.public.access.forms
|
| I'm trying to generate a new record based on a value typed in a form.
For example, I am purchasing 10 television sets. Once I type in 10 in the
Form, I would like ten new records to appear in a serial number table. The
serial number table would have an autonumber function and include the brand
of the television set and customer name.
|
 
Thank you for your response. I am lost in how to enter the code in Access. I'm hoping that if I give you specifics you will be able to tell me the exact code or process to generate the records.

I am unsure where to add the code as I rarely deal with writing code. I have a Form that is used to enter sales information. The Form name is Voucher Sales. In the Form the user is asked to Enter Voucher,Amount Sold, Days Nights (text field), and Sales Price. Once the user enters the data in the fields, the fields are updated in a Voucher Details Table.

I would like to have duplicate rows entered into a table based on the number keyed into the Amount Sold Field. For example, If I key in Silver for Voucher, 10 for Amount Sold, 3/4 for Days Nights, and $350 for Sales Price, then I would like 10 rows to be entered into a new table, which I have named Generate Vouchers. The fields added to Generate Vouchers table would be Voucher, Days Nights, Amount Sold. This data would be duplicated by the number keyed into the Amount sold field.

If it is easier to create an append query and then set a criteria under Amount Sold field, please let me know what the code is for the criteria.

Thank you for all your help.
----- \"prabha\" wrote: -----

Hi,

Here's a piece of sample code that should give you some ideas:

Function funcAppendToTable(strNumberOfTimes As Integer)

Dim i as Integer
For i = 1 To strNumberOfTimes
CurrentDb.Execute "INSERT INTO Table1 ( Field1, Field2, Field3 )
SELECT 'Z', 2, 'Y';"
Next i

End Function


The above function runs the INSERT INTO sql statement x number of times (in
a Loop) appending as you see the same values. Of course you could change
the values in the Loop if needed.


I hope this helps! If you have additional questions on this topic, please
respond back to this posting.


Regards,

Eric Butts
Microsoft Access Support

"Microsoft Security Announcement: Have you installed the patch for
Microsoft Security Bulletin MS03-026? If not Microsoft strongly advises
you to review the information at the following link regarding Microsoft
Security Bulletin MS03-026
<http://www.microsoft.com/security/security_bulletins/ms03-026.asp> and/or
to visit Windows Update at <http://windowsupdate.microsoft.com/> to install
the patch. Running the SCAN program from the Windows Update site will help
to insure you are current with all security patches, not just MS03-026."


--------------------
| Thread-Topic: Generate new records based on value typed in form
| thread-index: AcP6HpGK2udnn9+wRJuJ4NKMAkddgw==
| X-Tomcat-NG: microsoft.public.access.forms
| From: "=?Utf-8?B?TmV3QWNjZXNzUXVlc3Rpb24=?="
<[email protected]>
| Subject: Generate new records based on value typed in form
| Date: Mon, 23 Feb 2004 07:06:09 -0800
| Lines: 1
| Message-ID: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.public.access.forms
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.access.forms:256505
| NNTP-Posting-Host: tk2msftcmty1.phx.gbl 10.40.1.180
| X-Tomcat-NG: microsoft.public.access.forms
|
| I'm trying to generate a new record based on a value typed in a form.
For example, I am purchasing 10 television sets. Once I type in 10 in the
Form, I would like ten new records to appear in a serial number table. The
serial number table would have an autonumber function and include the brand
of the television set and customer name.
|
 
Here's a way not using code:

- I assume that textbox control on your Form that holds the field "Amount
Sold" has the same name for the textbox control "Amount Sold" and NOT
something like "Text127". Also the other textbox controls on the Form have
same corresponding name.

1- Create a new query in design view without adding a table
2- Select the menu option Query > Append Query
3- Select your table "Generate Vouchers" and click OK
4- For the Fields in the query set them up as follows

FIELD:
UPDATE TO:
Forms![Voucher Sales]![Voucher] Voucher
Forms![Voucher Sales]![Amount Sold] Amount Sold
Forms![Voucher Sales]![Days Nights] Days Nights

5- Save the Query as "MyQuery"
6- Create a Macro that has the following Actions and name it "RunMyAppend"
Action: Action Arguments
OpenQuery MyQuery (the query name)

7- Create another Macro and call it "RunNumberOfTimes" with the following
Actions
Action: Action Arguments
SetWarnings No
Run Macro RunMyAppend (macro name)
=Forms![Voucher
Sales]![Amount Sold] (repeat counts)
SetWarnings Yes

8- Create a command button on the Form (without the Controls Wizard on).
Right click the command button and select properties

9- In the properties window of the Command button select the event tab.
And for the OnClick event select the drop down box to choose the macro
"RunNumberOfTimes"

I hope this helps.

Eric


--------------------
| Thread-Topic: Generate new records based on value typed in form
| thread-index: AcP6gFvTYpftjUTnRxqpAvIIJah6Bg==
| X-Tomcat-NG: microsoft.public.access.forms
| From: "=?Utf-8?B?TmV3QWNjZXNzUXVlc3Rpb24=?="
<[email protected]>
| References: <[email protected]>
<NTX00tl#[email protected]>
| Subject: RE: Generate new records based on value typed in form
| Date: Mon, 23 Feb 2004 18:46:09 -0800
| Lines: 84
| Message-ID: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.public.access.forms
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.access.forms:256602
| NNTP-Posting-Host: tk2msftcmty1.phx.gbl 10.40.1.180
| X-Tomcat-NG: microsoft.public.access.forms
|
|
Thank you for your response. I am lost in how to enter the code in
Access. I'm hoping that if I give you specifics you will be able to tell
me the exact code or process to generate the records.

I am unsure where to add the code as I rarely deal with writing code. I
have a Form that is used to enter sales information. The Form name is
Voucher Sales. In the Form the user is asked to Enter Voucher,Amount Sold,
Days Nights (text field), and Sales Price. Once the user enters the data
in the fields, the fields are updated in a Voucher Details Table.

I would like to have duplicate rows entered into a table based on the
number keyed into the Amount Sold Field. For example, If I key in Silver
for Voucher, 10 for Amount Sold, 3/4 for Days Nights, and $350 for Sales
Price, then I would like 10 rows to be entered into a new table, which I
have named Generate Vouchers. The fields added to Generate Vouchers table
would be Voucher, Days Nights, Amount Sold. This data would be duplicated
by the number keyed into the Amount sold field.

If it is easier to create an append query and then set a criteria under
Amount Sold field, please let me know what the code is for the criteria.

Thank you for all your help.
----- \"prabha\" wrote: -----

Hi,

Here's a piece of sample code that should give you some ideas:

Function funcAppendToTable(strNumberOfTimes As Integer)

Dim i as Integer
For i = 1 To strNumberOfTimes
CurrentDb.Execute "INSERT INTO Table1 ( Field1, Field2, Field3 )
SELECT 'Z', 2, 'Y';"
Next i

End Function


The above function runs the INSERT INTO sql statement x number of
times (in
a Loop) appending as you see the same values. Of course you could
change
the values in the Loop if needed.


I hope this helps! If you have additional questions on this topic,
please
respond back to this posting.


Regards,

Eric Butts
Microsoft Access Support

"Microsoft Security Announcement: Have you installed the patch for
Microsoft Security Bulletin MS03-026? If not Microsoft strongly
advises
you to review the information at the following link regarding
Microsoft
Security Bulletin MS03-026
<http://www.microsoft.com/security/security_bulletins/ms03-026.asp>
and/or
to visit Windows Update at <http://windowsupdate.microsoft.com/> to
install
the patch. Running the SCAN program from the Windows Update site will
help
to insure you are current with all security patches, not just
MS03-026."


--------------------
| Thread-Topic: Generate new records based on value typed in form
| thread-index: AcP6HpGK2udnn9+wRJuJ4NKMAkddgw==
| X-Tomcat-NG: microsoft.public.access.forms
| From: "=?Utf-8?B?TmV3QWNjZXNzUXVlc3Rpb24=?="
<[email protected]>
| Subject: Generate new records based on value typed in form
| Date: Mon, 23 Feb 2004 07:06:09 -0800
| Lines: 1
| Message-ID: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.public.access.forms
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.access.forms:256505
| NNTP-Posting-Host: tk2msftcmty1.phx.gbl 10.40.1.180
| X-Tomcat-NG: microsoft.public.access.forms
|
| I'm trying to generate a new record based on a value typed in a
form.
For example, I am purchasing 10 television sets. Once I type in 10 in
the
Form, I would like ten new records to appear in a serial number table.
The
serial number table would have an autonumber function and include the
brand
of the television set and customer name.
|


|
 
Thank you for all your help

----- \"prabha\" wrote: ----

Here's a way not using code

- I assume that textbox control on your Form that holds the field "Amount
Sold" has the same name for the textbox control "Amount Sold" and NOT
something like "Text127". Also the other textbox controls on the Form have
same corresponding name

1- Create a new query in design view without adding a tabl
2- Select the menu option Query > Append Quer
3- Select your table "Generate Vouchers" and click O
4- For the Fields in the query set them up as follow

FIELD:
UPDATE TO
Forms![Voucher Sales]![Voucher] Vouche
Forms![Voucher Sales]![Amount Sold] Amount Sol
Forms![Voucher Sales]![Days Nights] Days Night

5- Save the Query as "MyQuery
6- Create a Macro that has the following Actions and name it "RunMyAppend
Action: Action Argument
OpenQuery MyQuery (the query name

7- Create another Macro and call it "RunNumberOfTimes" with the following
Action
Action: Action Argument
SetWarnings N
Run Macro RunMyAppend (macro name
=Forms![Voucher
Sales]![Amount Sold] (repeat counts
SetWarnings Ye

8- Create a command button on the Form (without the Controls Wizard on).
Right click the command button and select propertie

9- In the properties window of the Command button select the event tab.
And for the OnClick event select the drop down box to choose the macro
"RunNumberOfTimes

I hope this helps

Eri


-------------------
| Thread-Topic: Generate new records based on value typed in for
| thread-index: AcP6gFvTYpftjUTnRxqpAvIIJah6Bg=
| X-Tomcat-NG: microsoft.public.access.form
| From: "=?Utf-8?B?TmV3QWNjZXNzUXVlc3Rpb24=?="
<[email protected]
| References: <[email protected]><NTX00tl#[email protected]
| Subject: RE: Generate new records based on value typed in for
| Date: Mon, 23 Feb 2004 18:46:09 -080
| Lines: 8
| Message-ID: <[email protected]
| MIME-Version: 1.
| Content-Type: text/plain
| charset="Utf-8
| Content-Transfer-Encoding: 7bi
| X-Newsreader: Microsoft CDO for Windows 200
| Content-Class: urn:content-classes:messag
| Importance: norma
| Priority: norma
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.
| Newsgroups: microsoft.public.access.form
| Path: cpmsftngxa06.phx.gb
| Xref: cpmsftngxa06.phx.gbl microsoft.public.access.forms:25660
| NNTP-Posting-Host: tk2msftcmty1.phx.gbl 10.40.1.18
| X-Tomcat-NG: microsoft.public.access.form
|
|
Thank you for your response. I am lost in how to enter the code in
Access. I'm hoping that if I give you specifics you will be able to tell
me the exact code or process to generate the records

I am unsure where to add the code as I rarely deal with writing code. I
have a Form that is used to enter sales information. The Form name is
Voucher Sales. In the Form the user is asked to Enter Voucher,Amount Sold,
Days Nights (text field), and Sales Price. Once the user enters the data
in the fields, the fields are updated in a Voucher Details Table

I would like to have duplicate rows entered into a table based on the
number keyed into the Amount Sold Field. For example, If I key in Silver
for Voucher, 10 for Amount Sold, 3/4 for Days Nights, and $350 for Sales
Price, then I would like 10 rows to be entered into a new table, which I
have named Generate Vouchers. The fields added to Generate Vouchers table
would be Voucher, Days Nights, Amount Sold. This data would be duplicated
by the number keyed into the Amount sold field.

If it is easier to create an append query and then set a criteria under
Amount Sold field, please let me know what the code is for the criteria.

Thank you for all your help.
----- \"prabha\" wrote: -----

Hi,

Here's a piece of sample code that should give you some ideas:

Function funcAppendToTable(strNumberOfTimes As Integer)

Dim i as Integer
For i = 1 To strNumberOfTimes
CurrentDb.Execute "INSERT INTO Table1 ( Field1, Field2, Field3 )
SELECT 'Z', 2, 'Y';"
Next i

End Function


The above function runs the INSERT INTO sql statement x number of
times (in
a Loop) appending as you see the same values. Of course you could
change
the values in the Loop if needed.


I hope this helps! If you have additional questions on this topic,
please
respond back to this posting.


Regards,

Eric Butts
Microsoft Access Support

"Microsoft Security Announcement: Have you installed the patch for
Microsoft Security Bulletin MS03-026? If not Microsoft strongly
advises
you to review the information at the following link regarding
Microsoft
Security Bulletin MS03-026
<http://www.microsoft.com/security/security_bulletins/ms03-026.asp>
and/or
to visit Windows Update at <http://windowsupdate.microsoft.com/> to
install
the patch. Running the SCAN program from the Windows Update site will
help
to insure you are current with all security patches, not just
MS03-026."


--------------------
| Thread-Topic: Generate new records based on value typed in form
| thread-index: AcP6HpGK2udnn9+wRJuJ4NKMAkddgw==
| X-Tomcat-NG: microsoft.public.access.forms
| From: "=?Utf-8?B?TmV3QWNjZXNzUXVlc3Rpb24=?="
<[email protected]>
| Subject: Generate new records based on value typed in form
| Date: Mon, 23 Feb 2004 07:06:09 -0800
| Lines: 1
| Message-ID: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.public.access.forms
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.access.forms:256505
| NNTP-Posting-Host: tk2msftcmty1.phx.gbl 10.40.1.180
| X-Tomcat-NG: microsoft.public.access.forms
|
| I'm trying to generate a new record based on a value typed in a
form.
For example, I am purchasing 10 television sets. Once I type in 10 in
the
Form, I would like ten new records to appear in a serial number table.
The
serial number table would have an autonumber function and include the
brand
of the television set and customer name.
|


|
 
Back
Top