Button That Adds As Many Records As You Want

Mar 29, 2006

I want to create a button that adds as many records to a table as you want. So I would have
- a text field where the user would input the number of records
- the code of the button having a for loop or while statement to add that many records as the user typed in

This is my code of a button that adds one record at a time. My VB is not good so could someone tell me how to put in a for loop or while statement that would do the trick? Thanks.

Private Sub addbutton_Click()

If IsNull(Combo0) Then
MsgBox "Please select an Oil to add data (Top left corner)"
Else
Me![Property Subform].Form.AllowAdditions = True
Forms![Values Form]![Property Subform].SetFocus

DoCmd.GoToRecord , , acNewRec
Me![Property Subform].Form![TV_O_ID] = Combo88
Me![Property Subform].Form![T_TT_ID] = Combo86
'Weathering Info
Me![Property Subform].Form![WEATHERTYPE] = Text106
Me![Property Subform].Form![WEATHERUNIT] = Combo104
Me![Property Subform].Form![WEATHER%Num] = Combo102
Me![Property Subform].Form![WEATHER%Text] = Combo100
'Parameter Info
Me![Property Subform].Form![PARAMTYPE] = Combo114
Me![Property Subform].Form![PARAMUNIT] = Combo120
Me![Property Subform].Form![PARAMVALNum] = Combo112
Me![Property Subform].Form![PARAMVALText] = Combo110
Me![Property Subform].Form.AllowAdditions = False

End If

Me![Property Subform].Requery

End Sub

View Replies


ADVERTISEMENT

Single Form Adds Several Records?

Feb 9, 2008

Hi all,

I already have a form where you specific the date and the store I've purchased something at. I want to be able to add several products I've purchased to a table and define their price, using the same form, so I don't have to input the date and store type for each purchased product.

So, when the form updates the table, it will create a new record for each product, using the product description and price - defined for each product - and using the date and store - defined once - as elements of the record. Is there a way of doing this?

I'm quite familiar with creating tables, forms and queries with the design wizard - not so familiar with using scripts, but I've had a small amount of experience with manipulating databases using MySQL, so I'm willing to learn anything that may be necessary to achieve what I need.

Bugme

View 7 Replies View Related

Queries :: Append Query / Adds Records - Despite Key Violation?

Dec 3, 2013

- I have a module which runs queries on linked sales spreadsheets, to merge them in to one Access table.
- To prevent duplication of sales, the primary key merges the sales record and item number fields.

Today, it's found 103 key duplication errors, which is fine. But it's still adding data to the table. The data seems to be fields which aren't even mentioned in the query. It only does this when the query is ran from VBA.

Code:
MergeEbay = "INSERT INTO tblSales ( SalesRecord, SKU, PostCode, Shipping, Quantity, SalePrice, SalesRecordSKU, DateAdded )" & _
"SELECT exEbaySales.[Sales record number], IIf(exEbaySales.[Custom label] Is Null,'0',exEbaySales.[Custom label]), exEbaySales.[Buyer postcode], " & _

[code]...

View 3 Replies View Related

User Adds A Tab

Apr 4, 2006

I have a tab control with three tabs on it. Suppose I want the user to click a command button to add another tab and then add data to the fields within the tab. How would I go about doing this? Many thanks.

View 3 Replies View Related

Chart Adds Days

Jan 2, 2008

I have an access 2003 database that shows when customer concerns were reported and when thay were resolved. I have a query that calculates how many days it took for each concern to be resolved. I used the query to make a report that shows all concerns which took more than 14 days to be resolved. I want to show these concerns in a chart but it is adding up all the days for each month. For example, if there was one concern in December which took 15 days to be resolved and another concern which took 20 days to be resolved the graph shows this as one concern which took 35 days to resolved. I need to show a bar for each concern seperately instead of showing one bar of alll the concerns for one month. Does anybody know why this is happenning?

View 2 Replies View Related

Addnew Only Adds One Record!!

Nov 22, 2005

I have the following code which is supposed to insert a new record into TBLLetterHistory when a report is printed. The report is based on a Query which selects the records based on their postcode.

What actually happens is that only the first record in the query is inserted into the History Table. Any suggestions would be gratefully recieved as I have no idea, even after long searches in this forum!!


Private Sub Report_Activate()
Flag = 0
End Sub

Private Sub Report_Deactivate()
Flat = -1
End Sub

Private Sub ReportFooter_Print(Cancel As Integer, PrintCount As Integer)
Dim dbs As DAO.Database, rst As DAO.Recordset
Set dbs = CurrentDb()
Set rst = dbs.OpenRecordset("TBLLetterHistory")

Flag = Flag + 1
' If the current value of Flag = 1, then a hard copy of the
' report is printing, so add a new record to the history table.
If Flag = 1 Then
rst.AddNew
rst!ReportName = "RPTLetterByPostcode"
rst!Date = Now
rst!LeadID = [QRYLetterByPostcode.LeadID]
rst.Update
rst.MoveNext
' Flag = 0

End If
End Sub

View 9 Replies View Related

Forms :: Subform Adds Blank Record?

Nov 10, 2013

I have a subform that stays in data sheet view for entry, the form this sits on is launched by a macro. This macro on the main form launches the form and adds in the linking numbers by a setvalue. The main form has the linked number on it and this number is then linked by master and child to the subform. The problem comes in when you start adding in data. The line of data is filled by using combo boxes and some text fields and ends with a time/date stamp Now(). The problem is, even if you dont fill the entire line if a user refreshes or closes the form it adds a blank entry with the linking number but all fields blank.

View 1 Replies View Related

Queries :: SQL UPDATE That Adds But Doesn't Replace?

Aug 27, 2013

Right now, I'm working with an SQL code of

Code:
"UPDATE Individuals SET [ShareholderOf] = " & Me.CompanyNo & " WHERE [Name] = '" & PerName & "';"

However, doing so will obviously change the "Shareholder of" field into what the user inputs (Me.CompanyNo). What should I use if I want it to ADD the user input rather than REPLACING the old [shareholderof] value?

View 6 Replies View Related

General :: Create Addin That Adds A Tab To Ribbon?

Sep 24, 2012

I want to create an addin that adds a tab to the ribbon. I already have an add in installed that works exactly the way I want mine to, but I can't find the .mda file anywhere. I want to stick with the .mda so I have access to my forms. Here are some images of that add in I mention.

View 2 Replies View Related

Queries :: Make Table Query That Adds A Primary Key

Aug 8, 2013

I have a make table query that gets its info from another table that is updated weekly. I would like that when we run the Query Type (Make Table), we would like to add a primary key to a field that exists already starting at 1 every time the query is run.

View 3 Replies View Related

Reports :: Adding Page Numbers Adds Processing Time

May 15, 2013

I'm working on a pretty serious report (at least for me)...I have 3 sub-reports inside, and the point of this is to use VBA and loop through several conditions (in the underlying queries), and print out in a batch for the user. When I add a page number footer it adds about 3 seconds to the processing time for a 14 page report. That doesn't sound like a whole lot, but when I loop through and process this 12 times, that's a lot of added time for the user...(the last thing I want to hear is it's slow!)

So, would it be faster if I set the page numbers in VBA? What event would I use? On Load?!? Also, how would I find the page number variables in VBA?

View 1 Replies View Related

Reports :: Export From Access To RTF Format Adds Line Break

Mar 7, 2014

I have set up an access application with a report being exported to rtf format. Would prefer word format if it is possible.

In the export document created there are line breaks on every row. This creates headache when the exported text is re-used in a word document.

is there any way how to have the export where the text is kept together without line breaks on every row?

View 2 Replies View Related

Modules & VBA :: Recordset Adds New Record Into Subform But On Save Nothing Added To Table

Nov 5, 2014

I am adding new record into subform via recordsetclone method. The problem is that record is added but on save it does not appear in the table. If add this record manual using subform everything works. When record added manually update of the record works fine.

C
'Add Wastage value to flooring area section
Private Sub Wastage_AfterUpdate()
Dim rsFlArea As DAO.Recordset
Dim Wastage As Double
Dim Item As String
Set rsFlArea = Me.OrderFloorAreaEdit.Form.RecordsetClone

[Code] .....

View 6 Replies View Related

Forms :: Form That Adds Data To A Table Depending On Which Option Was Clicked In Combo Box?

Sep 30, 2013

i have a standard database with tblProducts, order, employees, customers, suppliers etc. i also have a table called tblperson with personID which acts as a one, with the many in three different tables (customers, suppliers and employee) the person table holds data such as first name last name address city postcode and phone. now, ive created a form called frmPerson that acts as a adding data to my database. ive got a load of buttons a working add, delete and a save button, i also have the option to switch through records next, last, end and first. now basically in this form i want to be able to add data i.e. fill out the text boxes and then have a combo box or something similiar that when i add the data i can basically click an option the says 'employee' 'supplier' or 'customer' and then the data gets added to my person table however the difference is that it will also be associated to the record in the wanted table.

View 14 Replies View Related

Tables :: Use Insert Into Command To Insert Filepath Into Table That Adds Blank Label

Aug 28, 2014

I am at work, and I have acquired a database that prints labels. They now want the database to be coded so that after certain labels are printed the database will print a blank label. I have the code figured out as a Do While statement in order to print the blank label. The problem I am having is that I am trying to use the Insert Into command to insert the filepath into the table that adds the blank label.

|DoCmd.RunSQL "INSERT INTO Rod_tmakLabels ( Print, [Order] ) SELECT Yes AS Expr1, 'Rods Labels' AS Expr2"|

If I run the above command, it just adds the text "Rods Labels" at the end of the table. Is there anyway with the INSERT INTO command that I can insert the new label between the 2nd and 3rd row and add another row? Or is the command designed only to add a new row to the end? I haven't had any luck searching for this yet.

View 1 Replies View Related

Subform Correct Answer Adds To Number Correct In Main Form

Mar 2, 2012

The code I have is.

Code:
Private Sub Command26_Click()
If Forms![test site]![prp test].Form.[A Right Answer] = -1 Then
Forms![test site]![number correct] = Forms![test site]![number correct] + 1
End If
DoCmd.FindNext
End Sub

Then when clicked it checks a yes/no box to see if "A right Answer" is the correct yes. Then it should pop to the main form and take the number correct cell and add one to it. I am trying to get the record to go to the next record inside the sub-form but docmd.findnext seems to be wrong too.

View 4 Replies View Related

Filter Records From A Button

Nov 17, 2006

Delete Reference: Trying combinations I found one that works!!!

The second line should read: Me.Filter = "AdminDateCompleted Is Null"



Hi,
I want to filter records from a form with a button to isolate all incompleted tasks.

Incomplete tasks are identified with an empty field [AdminDateCompleted] which is formatted as a 'Medium Date'.

I am having trouble with the following code (created after several hours searching this forum and experimenting).

First click returns all the records allegedly filtered, 2nd click turns the filter off and the third click returns 1 (Filtered) blank form.

If Form.FilterOn = False Then
Me.Filter = IsNull(Me.AdminDateCompleted)
Me.FilterOn = True
cmdFilterActive.Caption = "Remove filter"
Else
Me.FilterOn = False
cmdFilterActive.Caption = "Filter"
End If

I would appreciate any advice please.

Allan

View 4 Replies View Related

Button Deletes All Related Records - Help!

Feb 20, 2005

I have a problem where a button is deleting all the records related to one record, I was hoping somebody could help. Here's the problem:

OrderID is an attribute in table tblOrders. It is related (with Cascade update related records) to OrderID in tblTurkeys. In a form with a button which deletes a particular OrderID from tblOrders, when this button is clicked, if there are records in tblTurkeys with that OrderID, the record in tblOrders cannot be deleted. And if I changed the relationship type to cascade delete, the record in tblTurkeys will be deleted. Basically, I want the button to, before deleting the record in tblOrders, make the value of the OrderID attribute of any records in tblTurkey with the same OrderID as the one being deleted to have no value.

Eg. Record in tblOrders is being deleted. It's OrderID is 2. There are two records in tblTurkeys which have OrderID attributes of value 2, so when the record in tblOrders is being deleted, the values of the OrderID attributes previously mentioned as being in tblTurkeys now have no value.

That's what I need it to do! If anyone can help, I'd be greatly thankful!

View 5 Replies View Related

How To Make Button Generate Records

Aug 4, 2005

While there are lots of detailed issues discussed and resolved here, my problem is at a much higher level. Here's what I want to do.

I want to generate records in a file based on the user entering some 9 different values. The first two values will be used to get records from file A (they are a partial key). The values from the records in file A, plus the other values entered by the user will be used to generate records in file B. I hope this is clear enough.

I have created a query which prompts the user for each field and does the job just fine, but I want to replace the 9 individual prompts with a single form which allows the use of combo boxes for the partial key and a date picker for the single date field.

I've fluffed through creating a form with unbound controls to suit and even worked out a form of cascading combo box for the partial key, but I am struggling to find the best way to make a button at the bottom generate those records.

A nice optional would be to then display the added records (i.e. another query I guess).

Can somebody give me some pointers as to how to approach this? I've done very little in the way of Access programming, being mostly an SQL guy.

Thanks.

View 3 Replies View Related

Adding Records Only On Button Click?

Oct 26, 2005

Adding Records Only On Button Click?

I am building a database with a single table of records. I have created a form to allow new entries to be made to the table in a user-friendly way.

The problem I’m stuck with is how do I restrict the addition of new records on the form? I want the new record to only be added to the table upon the click of a button, but at present if I tab through, or exit the form the record is saved anyway.

Not all fields on the form are required input so I’m thinking that validation of every field is not the way to go.

I only ever want the record to be saved if a user clicks on a button and under no other circumstance.

I've been trawling through the posts back to about page 15 so any help would be appreciated.

Ksan

View 4 Replies View Related

Reports :: Button Associated With Individual Records

Aug 21, 2013

I have a button on a report that I want to use to confirm if the contents of a field were prepared or not. Below is the button vba:

Private Sub Command60_Click()
'retrieve the records
Static Count As Integer
Count = Count + 1
'
Select Case Count

[Code] ....

The problem with this is that it changes the text and background for every button in the report. I want the button to change its text etc for individual records in the report. and not all at one time. In other words I want each record to have a button, and each button associated with each record.

View 1 Replies View Related

Forms :: Add Button To Sort Records

Jan 19, 2015

Ive created a form and one of the fields is a field called "Due Date"

I want to create a button that once pressed will sort the records in order of due date with the oldest being record 1.

How I can get a button to manipulate fields.

Ive got a set of buttons at the bottom of my form (Ive placed them in the footer) that were set up using Access automatically. They go to first, last, next and previous records. Ive also set up two extra, one that creates a new record and another that sets the record.

The thing is that the set record button I would actually like it to take the data in a field called "Frequency", add a random number to it and then set the record.

View 1 Replies View Related

Coding Command Button To Add A Few New Records To A Table

Nov 2, 2006

I have 2 tables, one has a list of comments indexed by numbers.

The second table will be populated with numbers that correspond to the first table based on usage of the form that I'm about to describe.

The form contains several check boxes. Each corresponds to a comment from the first table. If 3 of the check boxes are selected when the command button is pressed, I want three separate new record entries to go into the second table and the data that I want entered is the text in the label that is next to each check box on the form. After the records are added to the table, I'd like to reset the check boxes.

I simply cannot figure out how to code the button to do this.

View 3 Replies View Related

Changing A Command Button According To The Number Of Records

Nov 13, 2007

I have a subform where you can add multiple records. i have a command button labelled NEXT (which obviously navigates to the next record) but I only want this to be enabled when there is more than one record.

I am OK on the enabling bit but how do you specify if the record number >1?

Does someone have time to start me off on some code?

View 1 Replies View Related

Forms :: Update Records On Button Click?

Jul 3, 2014

I have a form listing out a bunch of clients. There is a button associated with each client that pulls open a new form with additional client information. There is information that is calculated on the backend and stored in the database when a user is inserted or different fields updated (i.e. there are reports that are due different time frames after the clients admission date. I automatically populate the database with those dates once the clients admission date is updated).

The problem I am having is that when I enter a new client or update a current client with new information and then click the button to go to their details page, those auto-populated dates are not populated. I am calling a subroutine that is within a module when the button is clicked. The subroutine works fine at other instances throughout the application so I know there is no issue with the code. I even call it if they click the close button, but before the information is auto-populated, I had to run a Me.Requery on the close button. I think this is because the records are not actually being updated in the database. I even have a DoCmd.Save acForms, "Clients" command before running the Call updateDatabase subroutine, but that doesn't do the trick. I can't run the Me.Requery after the click of the details button because when I do that it always opens the details form to the first ORDER BY record. I think that I need to update the selected record and re-call it in order for this to work.

View 5 Replies View Related

Forms :: Button To Autofill A Field In All Records

Oct 21, 2014

I know all of the main features and can even do a bit with macros and VBA. I need creating a button to auto-fill a field in all the records in a table.

I have a database centered around a table called tblCand; each record contains a date field called intDate. On the main form, initDash, when the user hits a certain button, a window pops up (either a message box or perhaps a separate form) that asks the user to type in a date, which would be stored as intDateDB. When the user hits OK, I want the value of intDateDB to replace the value of intDate in all the records in tblCand.

I'm not sure whether this is called auto-filling or auto-populating...

View 11 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved