473,386 Members | 1,726 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Need to enter 5 records into same table with 1 button.

Dpot
30
I need a way to enter 5 records that have the same information with one button click. This database is being used to collect quality information, and instead of clicking a button 5 times for 5 parts, we'd like 1 button that when clicked once adds 5 records with different ID numbers; or 10 records if it's ten good parts.

The interval doesn't much matter, I just want to know if there is a way that we can click 1 button once and it'll but will put in multiple records with different ID Numbers (1, 2, 3, 4, 5, etc) but the rest of the information is the same (Part number, date, etc)

I tried
Expand|Select|Wrap|Line Numbers
  1.  Me.Id = Me.Id + 5 
and
Expand|Select|Wrap|Line Numbers
  1.  Me.Id = Me.Id * 5 
but it did the obvious. Didn't hurt to try.

Thanks in advance!
Nov 7 '14 #1

✓ answered by Dpot

Thanks for all the help... the following code does the job. Posting it in case anyone else may need it.

Expand|Select|Wrap|Line Numbers
  1. Dim sten As Integer
  2. Dim st As Integer
  3. Dim en As Integer
  4. st = IsNull(Me.ID.Value)
  5. en = IsNull(Me.ID.Value) + 4
  6. For sten = st To en
  7.    Me.Check401 = True 
  8.    DoCmd.GoToRecord , , acNext
  9.    Counter = Counter + 1
  10.    Command303.Caption = "Entered: " + CStr(Counter)
  11. Next

This will add 5 new records to my table at once.

7 1389
Dpot
30
Even tried Loop function, still didn't work. Any suggestions welcome.
Nov 7 '14 #2
twinnyfo
3,653 Expert Mod 2GB
Dpot,

I'm not sure I understand exactly what you are trying to do. I don't understand why you would be entering multiple records for one part.

Perhaps if you explained a bit better what it is that you are trying to do and why, we will be better able to assist.
Nov 7 '14 #3
Seth Schrock
2,965 Expert 2GB
There are basically two different ways to do this, both involving a loop. You can either use an unbound form and use the DAO.Recordset.AddNew method or you can use a bound form and use variables to store the data for the first record and then move to a new record, set the controls to the appropriate values from the variables and save. There isn't a "Right" answer for every situation. I'll let you decide which method works best for you.
Nov 7 '14 #4
Dpot
30
The operator does hundreds of parts a day.... with maybe 20 total bad parts. They do not want to have to sit there and enter every good part individually, she would like a way to enter them in in intervals of 5 or 10, just to save them time and frustration.. We need every part recorded, good or bad. We can't have 1 record that just says "5 good parts" we need 5 individual records displayed.

Here's an example of the code I was trying to use with the Loop function. It does EXACTLY what I want it to (puts multiple records in) but it will not stop, it just keeps going.

Expand|Select|Wrap|Line Numbers
  1. Do Until Me.ID.Value = Me.ID.Value + 5
  2.    Me.Check401 = True
  3.    DoCmd.GoToRecord , , acNext
  4.    Counter = Counter + 1
  5.    Command303.Caption = "Entered: " + CStr(Counter)
  6.    Me.Command303.BackColor = &HFF&
  7. Loop
  8.  
Nov 9 '14 #5
Seth Schrock
2,965 Expert 2GB
Because the second Me.ID.Value doesn't stay at its original value. So each loop is doing the following:

Expand|Select|Wrap|Line Numbers
  1. Do Until Me.ID.Value = 6
  2. Do Until Me.ID.Value = 7
  3. Do Until Me.ID.Value = 8
  4. Etc.
Before the loop, store the value of Me.ID in a variable and then test Me.ID against that variable + 5. Probably would be better to store Me.ID + 5 in the variable.
Nov 10 '14 #6
Dpot
30
Oh dur, I didn't even look at it that way. Thank you! I'll try it.
Nov 10 '14 #7
Dpot
30
Thanks for all the help... the following code does the job. Posting it in case anyone else may need it.

Expand|Select|Wrap|Line Numbers
  1. Dim sten As Integer
  2. Dim st As Integer
  3. Dim en As Integer
  4. st = IsNull(Me.ID.Value)
  5. en = IsNull(Me.ID.Value) + 4
  6. For sten = st To en
  7.    Me.Check401 = True 
  8.    DoCmd.GoToRecord , , acNext
  9.    Counter = Counter + 1
  10.    Command303.Caption = "Entered: " + CStr(Counter)
  11. Next

This will add 5 new records to my table at once.
Nov 10 '14 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Dave | last post by:
I have a form which is based on a table (a) with over 6000 records.I have a button on this form which will open another form with related data from another table (b). What I want to do is open the...
3
by: Larry Rekow | last post by:
As part of a macro, I'm trying to automate appending a table with new records. let's say the table 2 has some new records in it, but also has a lot of identical records to table 1. I would...
2
by: zeke | last post by:
Any assistance is much appreciated... I have a table with duplicate record information and I need to remove certain records based on values in four different fields. For example: PK field ...
5
by: Steve | last post by:
Hi, Is it possible to make hitting the enter key in an ASP textbox run the code behind an ASP button on a form? I have a search page which users tend to type in the query then just hit enter...
2
by: tlyczko | last post by:
I have a main form with 2 subforms, each subform references different data in the same table. How do I make sure each subform only creates NEW records in the referenced table and do not...
6
by: polocar | last post by:
Hi, I'm writing a program in Visual C# 2005 Professional Edition. This program connects to a SQL Server 2005 database called "Generations" (in which there is only one table, called...
2
by: kevinjbowman | last post by:
I am by no means a SQl Jedi as will be apparent by my question, but I can usually figure out a select statement on my own. I have one today though that really has me stumped. I am working in...
40
by: rdemyan via AccessMonster.com | last post by:
I have two databases, db1 and db2, with the same table, TableA. I want to select the records from TableA in db1 that have a LAST_UPDATE SomeDate. Then I want to get the identical records in TableA...
5
by: binky | last post by:
Question for all you SQL gurus out there. I have a (seemingly) complex query to write, and since I'm just learning SQL server, am not sure how to go about it. Tables: t_trans t_account All...
6
by: Mark B | last post by:
I have a function that looks up a SQL table to see if a search term matches. It works fine but so far there are two things yet to work: 1) After entering a search term and pressing Enter, nothing...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.