Have a table (tblDailyResults) with 4 fields (ID,TestName,Result,TestDate). It contains a snapshot of about 1,000 records. All fields have data except "Result", which is null. I also have a table (tblResults) with 3 fields (ID,TestName,Result), it contains about 100,000 Records of historical results. What I need to do is Update the "Result" field in "tblDailyResults" with a randomly select value from tblResults where the two testname match.
Im trying to make a query which will allow me to run a query update so that all my listings will get a new random number generated for them,
Ive got it selecting any listing with a ID of >0 (so basically thats all of the listings)
What id like it to do is then assign a random number to the randsort field, (prefer a number like 0.812 or 0.342 etc etc)
To start with ive tried using the Rnd feature, but its updating all the listings with exactly the same number (though granted the number changes each time the query is run)
I see in some of the other comments regarding rnd that you may need to put a randomize statement somewhere,
Im very new to programming in access and was just wondering am I on the right track, and if so where abouts should i declare the randomize code since its in a query?
Thanks for your time and look forward to your replies Cheers Ezy
hello all I am trying to set column values to a random number between 3 and 5
PMRatingTokenID: textH1: doubleYearID: textCode:UPDATE PMRating SET PMRating.H1 = (5+3-3)*Rnd()+3 This shows type mismatch error . What is the problem here..
I hope someone can help with this. I have a table, "Blasthole Submission" which is populated by input in a form, using the code below:
Const MyTable As String = "Blasthole Submission" Const MyField As String = "Sample Name" Dim db As DAO.Database Dim rs As DAO.Recordset Dim intCounter As Double Set db = CurrentDb Set rs = db.OpenRecordset(MyTable) For intCounter = Me.txtStartValue To Me.txtEndValue rs.AddNew rs.Fields(MyField) = "TP" & intCounter rs.Fields("Submission #") = Me.SubNum rs.Fields("Sample Type") = "Blasthole" rs.Fields("XRF") = "True" rs.Fields("LOI") = "True" rs.Update Next intCounter rs.Close db.Close Set rs = Nothing Set db = Nothing
What I am hoping to do is to place a random duplicate in the table, called, for example TP111152 DUP, approximately every 50th record. Is there any easy way of doing this?
If i have a table with several records let's say 1000 records, and each record has a field called cboCategory. Now from these 1000 records, lets say i have 200 records which has a value of CategoryA in the cboCategory field. Now is it possible that i extract "randomly" a number of records from that particular category chosen.
e.g.
Table -> 1000 records
records which belong to categoryA -> 200
extract 20 random records from the table which have a value of categoryA inthe cboCategory field.
As part of my job, each month I have to select 20 problem report resolutions and grade them on quality. Typically we have about 100 problem report resolutions per month. Is there a way I can use a query to return a random selection of 20?
I have to review 20 reports each month for quality check. I have a query that lists the reports completed within the past 30 days. Is there a way to filter this query to show only 20 random records?
If there is no way to do this, can you suggest some way of doing this so that it's impartial? For example I don't want to select the first 20 of the month because everyone will catch on and wait late in the month to post their report. Normally about 70 reports are completed in a month.
I've been using the following code to show Random records from an Access Database, the only problem with it is that every now and again it throws a "division by 0 error" any ideas how i can fix?
Code:strsql_videos = "select top 5 * from items ORDER BY RND(id)*(id*1000) MOD datePart('s', NOW()), id;"set rs_videos = server.createobject("ADODB.recordset")rs_videos.open strsql_videos, conn_videos, 3, 1, adCmdText
Iam hoping its possible with a few lines of code rather than some elaborate fix :P
I want to select at random 4 of these records and append them into another table along with some other data that the query will not pick up, in this case Pilot and Month.
I guess I am having to go the VBA route but dont have a clue on how to do it.
Cheers in anticipation.
Andy.
INSERT INTO Assignments ( flightcode, aircraft, depart, destin, pilotcode, [Month] ) SELECT Schedule.Flightcode, Schedule.Aircraft, Schedule.Departure, Schedule.Destination, [pilot] AS Expr1, [MONTH] AS Expr2 FROM Schedule WHERE (((Schedule.Departure) Like "man*"));
Is it possible to run a SQL command to update a field within a table with random numbers?
More specifically - random long integers linking back to an ID (autonumber) field in another table?
Background to this is, I have multiple static data tables related to each other by long integer identifiers (autonumbers)
The structure is fine but I haven't been provided with the actual data yet - but for development purposes, I need to work on other functionality which requires that this data be present.
So I want to fill my table with dummy data such that I can go off and work on the remaining functionality, but then just go back and clear it all out once I get the actual data.
I have one 'main' static table, which links back to other tables, which I have already populated with dummy static (i.e. company names, locations etc) Now I want to go into my main table and populate those fields in each record with a random ID. I don't mind doing this field-by-field (there's only a handful) but I've a lot of records in there (~1000) so I'd rather not do this record-by-record.
I am fairly new to Access 2013 but am trying to create a query that will select random records from three totally unrelated tables and display the results together as if one table -- think video slot machine wheels. Each table has two fields - ID which is the primary key and NAME. The data in the tables are names of states, names of colors, and types of animals. Each table has a different number of records. My end result is a table that selects X number of random records from each table and displays them side by side like this:
Desired Result: Animal Color State cat red Ohio dog blue Texas fox green Iowa
I have been able to create three individual queries that will pull X number of random records by using:
SELECT TOP 10 Animals.[ID], Animals.[Name] FROM Animals ORDER BY Rnd(-(100000*[ID])*Time()); SELECT TOP 10 Colors.[ID], Colors.[Name] FROM Colors ORDER BY Rnd(-(100000*[ID])*Time()); SELECT TOP 10 States.[ID], States.[LongName] FROM States ORDER BY Rnd(-(100000*[ID])*Time());
Using the three queries above I get three separate lists. how to make one query that will randomly pull from all three tables and make the display above?
I have a form which allows the user to add new records to a table. After the user had entered all the information into the form, they click a command button to add the record. In addition to adding the new record, my command button runs an query which is supposed to generate a random number between 1 & 1,000,000,000 and update the record ID field with that number.
Here is the formula I have been using in the "update To" now of my query: Int((1000000000-1+1)*Rnd()+1)
My problem is that I keep getting duplicates. You would think that the chances of getting a duplicate number would be pretty small with this large of a range, but I get a duplicate almost every time.
I have tried indexing (No duplicates) the field in the table, but that did not work. When my query generated a duplicate number, the record was just not added to the table.
I also tried a two step approach: 1-Make a table of all in use record ID numbers from my table (tblIdNo) 2-Update new record with a random number that is not in tblIdNo
This was a no-go too
How to build an update query that will update each new record added to the table with a random number between 1 & 1,000,000,000 without any duplicates? This seems like it should be so simple, and I am starting to get really frustrated.
I would prefer to accomplish this through a query/queries (if possible) rather than with 100 lines of code. This database is not for me, it's for another group, and the individuals in this group are totally freaked out by code.
I'm trying to insert 10% of a dataset from dbo_billing into another table Random_Temp. Another form is open when this query is to be ran that passess in the billyear and billmonth... I'm sure it's a syntax issue as I can isolate the random number part and it displays the appropriate data, I just can't re-write it to insert into the other table:
INSERT INTO Random_Temp ( indx, peopleId, audited ) SELECT TOP 10 PERCENT b.indx, b.peopleId, b.audited FROM dbo_Billing AS b WHERE (((b.billYear)=[Forms]![billing]![billyear]) AND ((b.billMonth)=[Forms]![billing]![billmonth]) AND ((b.recertifying)=-1)) ORDER BY Rnd(-(1000*b.indx)*Time());
I'm having trouble with my VBA module.I have a random test generator which pulls records based on a category from my table into a temp table using a make table query. I use the following code:
Private Sub Command2_Click() DoCmd.SetWarnings False DoCmd.OpenQuery "1", acViewNormal, acEdit DoCmd.OpenReport "WrittenExam", acViewPreview, "", "", acNormal Reports!WrittenExam.lblTitle.Caption = "Exam Name" DoCmd.OpenReport "WrittenExamAnswerSheet", acViewPreview, "", "", acNormal Reports!WrittenExamAnswerSheets.lblTitle.Caption = "Exam Name - Answer Sheet" End Sub
My querry makes the table, and then generates two reports (my exam, and the answer sheet). I'm getting an error 3211, saying the temp table is already in use by another process when trying to generate both reports. I used a Macro before, but I have a need for custom report headings, so I'm using VBA.
I have got a query that updates details from one table2 to table1, "Reference" is the primary key and this is what the query uses to determine which need updating.
It all works great but if table2 contains a record in "Reference" that is not in table1 i just want it to ignore it, currently it just seeems to add them.
I have a table called tblCompanies. When a company acquires another company, I need a method by which the acquired company's CompanyID (PK) can be updated to the new company's CompanyID (PK). I also need to be able to update all related CompanyIDs (FKs) to the new value in related tables.
In cases in which the new company does not have an existing record, there is no problem: the company name simply gets changed to the new company and the existing CompanyID is maintained. I then use an audit table and Track Changes function to keep track of the company name data and a union query to keep the old names in the selection lists.
The problem is when both companies already have existing records in the table.
So, let's say I have records for Company A and Company B. Company A merges with Company B and Company B is now the main record. What is the best, simplest and easiest way to update the CompanyID (PK) from A to B and change the CompanyID (FK) to the new value in all related tables?
I am envisioning a pop-up form that directs the user to select the new company and then an update query happens behind the scenes... but exactly how does the criteria for the update query get selected and how do all the related tables get updated? My vba skills are pretty basic, will I need extensive coding to do something like this?
Erm, I know this sound a bit silly....but I woudered if there was a way of adding anew record to a table using vb code?
My table is called tblTransmissions
The fields are TransmissionCode, AutoNumber TransmissionDate, Date/Time TransmissionTime, Date/Time TransmissionStatus / Text TransactionCode / Number (Linked to another table by One-To-Many)
When I hit a command button, I would like to update the recordset by firstly adding a new record. Then set Date & Time to Now, Then TransmissionStatus to a control on a form, same with the Transaction Code.
Normally I would place the values on a form and update the values that way, but just wondered if this was possible!
I am chasing a quick solution to what I am sure is a simple thing.
In my database I have a table of items that have to be held for different periods of time (one item type kept for 5 years, another for 3 etc). In another table, linked to the first through the item type, I have dates entered against records which, using the first table, will calculate the date I can get rid of the item.
My problem is that the period of time for some items to be held has now changed, and I want to change all the relevant records to update to the correct disposal date.
I have tried just changing the period items are held for (in the form), and that will provide the correct date for future records, however I want to refresh the old records as well so they are all correct.
Is there an easy way to achieve this without going through each individual record.
What I am doing is attempting to update a table through a form. I have been reading up on update queries, but I am not quite understanding how to use them. I have a table containing consumables that we constantly issue and receive. I have a form for each of these functions. Example: I order two ink cartridges from a vendor through a purchase order. When they arrive, I would like to enter the qty. I am receiving, then have it automatically add it to the table value. I don't know where to implement the arithmetic. Also, for PO's with multiple items, what's the best way to update the table with those?
The problem is I removed my primary key (if you can even use a primary key for this) and there's no record number option on the query. I just need 800, it doesn't matter which 800.
I was thinking of adding a field with a series of unique identifiers, but I don't know how to autofill sequentially.
Hi all I have a table "tblEmployee" which has "name, employee_no, manager, etc" I recieve from HR a updated spreadsheet which can have new employees or just updates. ie new manager name. I can run an update query to update changes based on the employee_no which is constant. How can i add new starters from this list ?
I am a new user to MS Access and i'm creating a stores account for my works, however i'm having problems with the updating of records after colleagues have been issued with kit. I have three table (employees, kitlist and issuelist) what i want is that when i issue kit to employees this updates the item in the kit list to reflect that i have issued an item, ie. take the number away from the units in stock. This is probably really easy however cannot find a solution to this problem.
I have a couple questions I hope that you can help me with. I have an asp page that is retrieving a bunch of records from an Access Database based on a field value (in my case its based on Department). They are then placed in a table format in the asp page. The user can then modify one or many records. Everything was working fine and then we upgraded our IIS Service from IIS5 to IIS6. Once we did that I started getting errors. I was able to update certain departments and not others. This told me the code was good and that the database permissions etc were good. It has to do specifically with the value or similar. I looked further and came to realize that it appears there were to many records to update. The Departments with a few records updated fine. THe ones with 500-1000 were erroring out. I went into the database and deleted the records from 1000 to 500 and everything works.
Does anyone know if there is a record limit to update?
Is there a function on ASP that I can use like Me.Dirty that will search first for updates and then just update the single record?
Is this a result of IIS6?
Here is a bit of my code: This is the area that it is bombing out on....I am not an expert and believe I might have hit an ARRAY size limit. Does that make sense?