I want to return all the records in a table in a random order. I have a query with Expr1:Rnd([RecordID]) sorted ascending as one of the fields. I have a form with this query as the data source.
This works fine, each time I open the form, I get a different record order.
I now want to use Randomize to return a different order each time I run the database.
Using advice from other threads about randomization, I have put the Randomize in the OnLoad event of the form, immediately followed by Me.Requery, but I still get the same first record each time I open the database.
I put Rnd() in a MsgBox after Randomize to see if the randomization is working, and I get a different number every time, it just seems that the Requery is being ignored.
I am trying to recreate (with many changes) a database that I have previously made, but the requery macro is not working. On my previous database, I typed the following in the row source:
SELECT [sub-activity].[Sub-Activity ID], [sub-activity].[Sub-Activity Name], [sub-activity].[Activity ID] FROM [sub-activity] WHERE ((([Combo23])=[sub-activity].[Activity ID]));
Now when I type it in my new database, the WHERE part of the statement is causing nothing to appear in my combo box. Does anyone know why that would be and what I can do to fix it? Thanks so much. :)
I have an "On Double Click" code in the second Combo box of a cascading combo box set. The code below works fine on a normal Combo Box, but for some reason the Requery statement doesn’t seem to have any effect in this instance. The data that has been entered into "FRM_DelPoint" does not appear (in the second Combo box [Combo18]) unless the First combo box in the set is changed :mad:
What have I got wrong?
Private Sub Combo18_DblClick(Cancel As Integer) On Error GoTo Err_combo18_DblClick Dim lngcombo18 As Long
If IsNull(Me![Combo18]) Then Me![Combo18].Text = "" Else lngcombo18 = Me![Combo18] Me![Combo18] = Null End If DoCmd.OpenForm "FRM_DelPoint", , , , , , acDialog DoCmd.GoToRecord , "FRM_DelPoint", acNewRec Me![Combo18].Requery If lngcombo18 <> 0 Then Me![Combo18] = lngcombo18
Exit_combo18_DblClick: Exit Sub
Err_combo18_DblClick: MsgBox Err.Description Resume Exit_combo18_DblClick End Sub
I have a 'frm_New_Client' which adds a record to a 'tbl_Individual' and updates info in 'tbl_Case.' Then I try to use some code to requery another form which is based on the same table. In the past, this code has worked, but something is wrong here. When I use the code to requery another form, that other form is not requeried at all. When I go to that other form and push a button with "Me.Requery" underneath, it requeries those tables with updated info, but does not bring in new records from the appended table. If I close the form and reopen, then all the new data is there--shouldn't I be able to do that without closing the form?
All tables are linked. What am I missing? Here is my code from frm_New_Client:
'requery my other form Forms![frm_Face_Sheet].Requery
New to access...just build a form, in which there are combo boxes....cascading of boxes was done.
Now the problem is I want afterupdate function to get activated when user changes the value of one combo....for which I have created a code in code builder... see the code... I think I am making a mistake in writing the code to requery...
I have a form with two subforms. One subform is a datasheet that pulls data from a temp table. During the other subforms Form_Current, the temp table is emptied (DoCmd.RunSQL "Delete from tblAddRefs"), reloaded with data relevent to the current record, and requeried (Forms("frmEDFP").Controls("tblAddRefs subform").Requery). This works like I want it to...
With the exception of the initial load of the main form. The subform based on a table shows (#Deleted) instead of data. if I step through the code, I can see that the temp table is emptied and repopulated by the time I try to requery the subform. This is still happening during the Form_Current of the other subform, which is successfully running on main form load.
If I requery (Forms("frmEDFP").Controls("tblAddRefs subform").Requery) using a button on the main form once it is loaded, the #deleted data is correctly is replaced by regular data, so it's like the requery in the Form_Current event isn't doing anything during load.
I have about 100 quiz questions in a MDB File. I need them to be randomized. I've done a pseudo-randomization of the questions by a certain column by using the ascending/descending order, but it is awfully obvious!!!
Is there a way to do it so it's like an ipod shuffle. Is there a way to randomly mix all the questions up WITHOUT the need to randomize by virtue of ascending/descending order of a column?
I need to randomise participants in an Access 2000 db into four groups. Let's say these are 1, 2, 3 and 4. This in itself is not the problem. The problem is that I need to keep the numbers of participants in each group approximately equal, say to within a tolerance of 4.
Can anyone point me in the right direction please?
I have read a lot about the rnd function to succesfully randomize the order of records in a db. I want to randomize 2 columns separately . These are Q's and A's so if the db is 2 fields (the second -small- letter is supposed to be under Field 2!) Field1 Field2 A a B b C c D d
etc... I want it to look like Field1 Field2 B c A d D b C a
I have managed to construct two separate queries which obviously give 2 random lists for each field but how to put them both together to achieve the above? I have tried applying a rank order to each list and then linking them on that but the rank number keeps changing hence no link there. All I want is to link them and keep each column in the same order as it has been randomized. Thanks
SELECT TOP 1 [Table].[QuestionText], [Table].[Answer] AS CorrectAnswer FROM [Table] GROUP BY [Table].[QuestionText], [Table].[Answer], rnd([IDQuestion]) ORDER BY rnd([IDQuestion]);
SELECT TOP 3 Table.Answer AS Correct, qQuestionTextAndAnswer.QuestionText, qQuestionTextAndAnswer.CorrectAnswer FROM [Table], qQuestionTextAndAnswer WHERE (((Table.Answer)<>[qQuestionTextAndAnswer].[CorrectAnswer])) ORDER BY Rnd([IDQuestion]);
These queries are displayed now in an Access form "frmQuestions" which is applied to "Table" that has three columns id, text , and answer. The result is one question and four suggested answer with one only being correct.The arrangement of the answers is randomized-- but the choice of the question is not realy random....it always starts with the same question as it relies only on rnd.
can I improve the queries and randomize and rnd in the same ...or else can I switch these queries to be used from vb6 code and achieve that result.
any help would be appreciated.
By the way I am really a beginner at this who is seeking help from the experts.
I have a table (tbl_entry) of performers and the different sections they are performing in. I can pull the performers for each individual section but is it possible to then give the performers a random number that will indicate the order in which each will perform. Eg: 5 performers in section 21a
Molly Mary Mike Merv Mandy
So can I get access to randomly assign numbers 1-5
I have a program that runs under access 2007 that I use at my work. We will soon be updating to MS office 2010 and the program will not work now because a calender file .ocx was removed from access 2010. Is there a way to get the 2007 .ocx file to work in access 2010?The program I am using is a relatively simple stand-alone and unsupported app that we use to request patient arrival and departure from various radiology tests inside a hospital. No reports are made from the app other than the number of patient transports for the day.
The app is placed on a common drive accessed from any pc in the hospital. No special permissions are required. But our app does use the calendar, time and date functions in access 2007. When I tried the app on a pc with access 2010, it basically says it (access) cannot open the app because a .ocx file is not present.Is there a way to make the access 2010 calendar file work in access 2007?
I have an Access 2010 database with two tables and two forms. The tables are Organizations and People. Similarly, the forms are Organizations Entry Form and PeopleEntryForm. The People are linked to the Organizations table. Several people can be linked to the same organization.On my Organizations EntryForm, I created a command button to duplicate a record using the wizard. It works fine.
I did exactly the same thing on the PeopleEntryForm, but instead of copying the record, it creates a new blank record. I don't get any error messages. Is my problem due to the fact that the People table is linked to the Organizations table?
Hi, I have a search form and a form that display the result of the search based on the search criteria from the search form. The query works just fine and the search results are displayed well but the problem is the following: the query doesn't work with the new records inserted in those tables, only records that were in the table at the moment i had developed that search button are displayed. If someone can tell me if there exist a sort of "requery" method for that query to display the new records.
I have a combo box [product] on my main form. On AfterUpdate of the combo I have it set to run a DLookup on a query (which is created with "tblPlan") and place that calculation in another field [costsavings]. This is working great, however, I update tblPlan each month and want it to update the calculation when I open the form instead of having to re-select the product again to trigger the query.
I have tried Me.Requery and Refresh for both the form and the combo on the main form's OnOpen and OnActivate events and it does not work.
Could someone please tell me where I need to place the code?
I have a form ("Clients") that points to a "Clients" table. I also have a form ("AddEditClient") that points to same table.
Open Clients form and you see client info. Have at the bottom 2 buttons. One to create a new client and one to edit the current client. B/c we do not want user to edit clients from main client form (most fields are locked on this form). So if the user clicks on "edit client" button takes them to same record on AddEditClient form... now they can edit the client (fields are not locked). If they click the "add client" button it takes them to a blank new record on the AddEditClient form. To this point all is good.
On the AddEditClient form there is only one button ("Finished" button). If they were editing an existing client I want it to return them to the same record on the client form and making sure to display the new data. If they added a new client then I want it to display that new client on the client form. If selected the new client button but then did not add a new client and simply hit finished then it opens the client form on the first record of the client table. I have it half way working right.
My problem is that if they added a new client then it does not send them back to that client. I think I need a REQUERY statement... but it seems that no matter where I put it, it breaks my opening of the correct record and then starts sending me back to the first record of the client table. My current code for the "Finish" button on the AddEditClients form is below. There is some extra stuff in there b/c I have been playing around with this for a day or two now.
Where does the requery statement go (and what is the proper syntax)? (or if this is a bad way to do this... how am I "suppose" to do it?) I had toyed around with closing one form before opening the other but then I was unable to pass back and forth my client id (key index number). As it stands now, I can not get my data refreshed (mainly a problem if a new client was added). If I put in a requery statement then I lose my position on the Client Form. So now the user would have to search for the client again. I feel like I am running in circles.
Client Form ---> points to Client Table but is essentially read only AddEditClient Form ---> points to same Client Table but has full access ClientK_ID ---> the key index for the Client Table... the field I am trying to use to navigate the tables from the two forms.
Dim stDocName As String Dim stLinkCriteria As String
stDocName = "Clients" If Me![ClientK_ID] > 0 Then DoCmd.Close acForm, "AddEditClients", acSaveYes
Else DoCmd.Close
End If
Basically I just want to be on a client... click an "edit" button to change their info. Then click a "finish" button and return to a mostly read only screen for that client. Or if I need to add a new client... click an "add" button... add a client then click "finish" and open that newly added record as mostly read only.
Unfortunatly I can't do this as a mode change... because on the Client form there are a few fields that are not read only.
I have a form which consists of an unbound combo box and two subforms. Now i would like that when i will select a value from the combo box, the two subforms will display the related records based on the combo's selected value.
What is the correct syntax to requery the subforms, after i select the value from the combo box?
I have been reading a earlier post regarding requerying forms
Forms are displayed on other form by means of a SubFormControl. It is the name of the SubFormControl that is needed. This is often the same as the SubForm but it is *not* a requirement. In your case you will be using two SubFormControl names, one nested within the other. Just for the record, you Requery forms and not fields.
How do you find out the name of the SubFormControl. I am trying to refresh sub forms and I am trying to use the following code.
Private Sub Form_AfterUpdate() Forms!MainFormName!SubFormControl.Form!SubSubFormC ontrol.Requery End Sub
I have 2 forms, "frmMainClient" and a subform "frmjob" and I have a command button on the "frmJob" which brings up a pop up form " frmJobNew". I fill out the fields and save via a command button.
When I look at the "frmJob" the new record I have entered is not there. It is there if I close all the forms and then open them again.
I know I need to requery the forms but I am not too sure how this is done.
I'm trying to requry a sub form based either or both text boxes. I need help with the code. I'm trying to rewrite something from a sample but can't seem to get it to use the criteria. It does requery though.
Private Sub cmdSearch_Click() Dim sCriteria As String sCriteria = "WHERE 1=1 "
If Me![Search] <> "" Then sCriteria = sCriteria & " AND MedicalRecordsUpdating.SerialNumber """ & Search & """" End If
If Me![SearchEvent] <> "" Then sCriteria = sCriteria & " AND MedicalRecordsUpdating.Event """ & SearchEvent & """" End If
I am sorry if this has been asked already a million times already but I could not find any relavant information in the time I had.
I have a requery / refresh problem.
I have a Customers form showing all customers, I also have a NewCustomer form for adding new customers.
On the Customer form, on activate I have me.refresh
On the NewCustomer form I have in the onclose,
If IsLoaded("Customers") Then Forms!Customers.Requery
These work well however if Customers is open and I enter a new record in the New Customer Form, then view the Customer form again the new record is not shown.
I can however click back on the NewCustomer from then straight back to Customers and Hey Presto it appears
Any clues as to what I need to do to update the form?
A user yesterday informed me I need a me.requery. I have a form with tabbed pages. First page I complete details of clients - second page goes into more detail. On second page I have a combo box listing all clients in alpha order. I want to get the new client I have just completd on first page into that combo box without having to close and re-open form. Does this code go against combo box, or page? Is there anything I need to add to this code, like form name? Have tried in various ways without success.