Forms :: Return To Previous Current Record After Requery

Jul 30, 2013

I have a Main form that has button that loads a new Pop Up form for entering new data that will display in the Main form. When all the data is entered I click on a button that Saves the data and exits the form and then runs Re-query on the main form returning to the record that was current before the requery.

I have the following code:

Private Sub cmdSaveTradeAndExit_Click()
DoCmd.RunCommand acCmdSaveRecord 'Save the current record
DoCmd.Close 'Close the current form
Dim CrId As Integer
CrId = Forms!frmTransactionMainActivePopUp.CurrentRecord
Forms!frmTransactionMainActivePopUp.Requery
DoCmd.GoToRecord , Forms!frmTransactionMainActivePopUp, acGoTo, CrId
End Sub

But I am getting the following error:

Run-time error '2498':

An expression you entered is the wrong data type for one of the arguments

And the following is in yellow in the debug:

Code:
DoCmd.GoToRecord , Forms!frmTransactionMainActivePopUp, acGoTo, CrId

View Replies


ADVERTISEMENT

Forms :: Event Procedure - Return To Previous Record

May 8, 2013

I'm trying to create a security measure that would prevent a user from accidentally paging down in a form and moving to the next record. I want to create an event macro that would fire if the user accidentally paged down into the next record. The macro would simply move back to the previous record.

What event would I use to build the macro ? What action would return to previous record ?

View 10 Replies View Related

Requery And Return To The Same Record

May 26, 2005

I have a form in spreadsheet view. Basically all I want is to update the information which is viewed, but Form.ReCalc doesn't requery the database. So I tried Form.Requery. But after doing Form.Requery, the first record of the form becomes the active record, and in some cases I have to scroll to see the record that was active before the requery. Is there any way to avoid this?

One possible I solution might be to requery that form and return to the record which was active before the requery. Here comes another problem. The form has a subform in spreadsheet view (which is viewed by clicking + to the left of any record in the first form). If I expand an record to view the sub form, it is also expanded after the requery, but I also want the main form to scroll down so the subform is fully visible (or as visible as it was before the requery), or alternatively, scroll down so the top most record in the main form that is visible also is the top most visible record after the requery. If this is not possible, maybe there is a way to make the record which was the active record before the requery to be the top most visible record after the requery.

Could someone point me in the right direction? Give any suggestion?
Any help is appreciated.

View 8 Replies View Related

Moving To Current Record After A Requery

May 4, 2006

I have a subform where the user enters the number of training days on a quotation. After the record is updated I do a requery on a text boxt on the main form that shows the total number of training days ordered for that particular customer.

The problem is the focus then resorts to somewhere else on the main form but I want it to return to the same record on the subform. I have managed to get it to go to the first record in the subform but obvisouly from users perception that is not god enough.

I have got the following code in the sub form's after update event but nothing seems to work although I do not get any errors.



Private Sub Form_AfterUpdate()
If Me.TrgType = 1 Then

Dim rs As DAO.Recordset
Dim varBookmark As Variant
Set rs = Me.RecordsetClone
rs.FindFirst ("QuoteItemID = " & Me.QuoteItemID)
varBookmark = rs.Bookmark
Forms!frmCustomer!txtUnitsOrdered.Requery
Forms!frmCustomer.Refresh
Me.Bookmark = varBookmark
Me.QuotedPrice.SetFocus
rs.Close
Set rs = Nothing

End If



Any assistance would be most appreciated :)

And yes Ghudson I have done a search - LOL :p

View 1 Replies View Related

Requery Form And Goto Its Current Record

Apr 19, 2006

I'm requerying a form after an update.

I would like to have the form to be set to its current record when being requeried. How can I easily achieve this?
I've seen things about recordsets, I'm working with ADP (based on SQL Server) and don't know or all DAO events will help me.

View 3 Replies View Related

Dynamically Update Field Of A Current Record Based On Previous Record

Apr 30, 2007

I need a way to dynamically store a particular value in "field_2" of the CURRENT record depending on whether or not the value of "field_1" of the CURRENT record is identical to the value of "field_1" of the PREVIOUS record within the same table. The table is sorted on "field_1".

So, if the value of "field_1" in the CURRENT record is "ABC" and the value of "field_1" in the PREVIOUS record is also "ABC", then store a value of "PPP" in "field_2" of the current record. IF on the other hand, the value of "field_1" in the CURRENT record is "ABC" and the value of "field_1" in the PREVIOUS record is "XYZ", then store a value of "WWW" in "field_2" of the current record.

I have a report that will use these results to count only the number of records that have a "WWW" in "field_2".

Is this doable, maybe in a query somehow?

I should add that whatever the solution, it needs to be compatible with Access 2000.

View 1 Replies View Related

Queries :: Evaluating Current Record To Previous Record To Get Counts

Aug 8, 2014

I'm struggling with a query to evaluate current and prior record data. I have a query producing 5000 records. I need to group records by Case ID and compare current date record to previous date record to determine if a team and worker name has changed during the year. I need to count how many times a cases is transferred to and out of a particular team from the beggining of the year. i.e., On 1/1/2014-Team1 has an inventory of 500 cases.

During the month 25 cases are transferred into Team1 and 15 cases are transferred out of Team1. So on 2/1/2014 Team1 begins with an inventory of 510 cases. Throughout the year cases come and go from and to Team1 each month so need to figure out how to create a query to count each change. See attachment displaying how the data is listed and how I invision it to work with the In/out column counts.

Specifically, at the begginig of the year (1/1/14) for case ID 1003 you can see it belongs to Mary in Team1 for January and February. Then in March the case is transferred out and went to Joe in Team 3. So for Mary a "-1" is recorded as a negative count for that Case ID. If later in the year the case is transferred back to Mary a "+1" would be recorded. Respectively evaluated for each of the 5000 records to get a total count for each of the teams by Case ID throughout the year.

I've started with DLookup, tried comparing current month to previous month using DMax. It works as long as I only select one case ID used in a separate query but if I use the whole subset (5000 records) it fails. I can't figure out how to group each set of case IDs and then apply the query.

My attempted query: DLookUp("[Team]","[Team_qry]","[Team_qry]![Date]=#" & CStr(DMax("[Date]","[Team_qry]","[Team_qry]![Date] <#" & CStr([Date]) & "#")) & "#")

View 3 Replies View Related

Refer To Previous Record In Current Record Query

Sep 15, 2005

In my query, i want to automatically display the value of another field from the previous record in a field in my current record. i.e.

Name Value Previous
Record 1 1
Record 2 2 1
Record 3 7 2
Record 4 1 7

Is it possible to create some kind of simple expression to refer to data in another record?

Cheers,
Ben

View 6 Replies View Related

Forms :: Lookup Value Dependant On Previous Field Entry - Requery?

Jun 21, 2015

I'm creating a database which contains information for keeping dog grooming clients. It has 3 tables, table 1 is customer, table 2 is dog, and table 3 is booking.I want to be able to choose the customer table and within that you can see the pet linked to that customer and within the dog table you can see any bookings with that dog.What I have done is linked the pet and booking table to the customer details via mobile no. being the primary key.

I want a form called appointments which contains fields *ID, date, mobile, dog name, grooming stlye and other. What i want to happen is this, once the mobile number is entered, i then when it to lookup the mobile number in the dog table and pull the pet name from that, then in the dog name box it will then provide a drop down of dogs related to that mobile number.

I understand a query needs to be made in the dog name field, so in that field i created a query to look up the mobile no. in the appointment table, and to then lookup the pet name in the pets table. This kind of works. The two problems are this, the drop down in the dog name field shows all of the dogs in the database not just the ones assigned to the mobile no. in the field before. If i choose one of the dogs not related to that mobile it changes the mobile number in the field before to the relevant one (but i don't want to be able to see the dogs which arent related to the mobile no. in the field before.The other issue is that on one of the customers there are two dogs, now on the drop down you can see both dogs, but it will only allow you to select the dog that was entered first into the database. If i select the other dog it simply chooses the data for the one first entered.

I have read about doing Requeries on the afterupdate of the field and attempted this by choosing the dog name field and in the afterupdate telling it to requery pet name (I've also tried mobile), this hasn't worked. I have a feeling I'm getting a bit confused by which fields i'm supposed to use etc.

View 1 Replies View Related

Compare Current To Previous Record In Query

Aug 14, 2007

I have a table of customers who report trouble on their equipment. I would like to compare the date in the current record to the previous record to see if it occurred within 30 days. Can I do this with an SQL query or expression?

View 2 Replies View Related

Queries :: Datediff From Previous To Current Record

Oct 10, 2013

I want to get the datediff of the last returned date from vacation and the current vacation start date. But how to get difference from the previous record's date to this current record's date. I want to show date difference in an unbound textbox. I have a contiuous form which shows all vacation list of employees. It shows how many times he went vacations and when he went and when he returned.

View 14 Replies View Related

Conditional Format Based On Previous And Current Record

Feb 4, 2005

I'm having trouble with a tricky conditional format in a continuous subform.

The criteria is based on field [GroupNo] when it changes (increases) which are always listed in numerical order.

Basically all I want to is for the text box colour to alterante (eg blue & yellow)when GroupNo changes value

So it would look something like this....

Group NoID (highlight colour)

1 (yellow)
1 (yellow)
1 (yellow)
2 (blue)
2 (blue)
2 (blue)
3 (yellow)
3 (yellow)
etc etc

btw, although values will always be in order they may not all be output, so it's not just case of odd, even, odd, even (that would be too easy!)

I can retrieve the Previous Record's GroupNo value (via a function) in another text box and compare current GroupNoID with this in the Format Expressions and manage to change the colour, but it won't sustain this new colour for the subsequent same GroupNos, obviously as the values have changed.

So how can I....

Change the colour when the value changes.
Keep this new colour until it the value changes (increases) again.

Many Thanks

View 14 Replies View Related

Modules & VBA :: Subtracting Value On Current Record From The Value Of Previous Records?

Jun 5, 2013

I want subtrack a value on the current record from the previous record and display the result in text box in subform datasheet. This is done during data entry. The calculation works most of the time and randomly it returns the wrong value. I have the code in an after update event after I enter a number. Here is what my code looks like:

sysHopSpacing = Abs([sysHop1] - DLookup("[sysHop1]", "tblSystemConfiguration", "[sysBaseNumber]=Forms![frmTempestCoordination]![frmSubSystem]![sysBaseNumber] - 1 "))

This is how I generate the sysBaseNumber

sysBaseNumber = Nz(DMax("sysBaseNumber", "tblSystemConfiguration", "sysAccountID=" & Forms!frmTempestCoordination!accAccountID), 0) + 1

I am using DMax so I can keep the subform records with the parent form record.

My results are inconsistant:

This is what I want the subform to do when subtracking from the previous record

syshop1 sysHopSpacing
5
20 15
30 10

Instead I get a result that does not make sense like this:

sysHop1 sysHopSpacing
5
20 15
30 4

I cant trace it down.

View 14 Replies View Related

Requery A Previous Form

Apr 30, 2006

Silly query, think I am missing something obvious but I shall ask anyway.

I want to update certain lists in my form do the user can select from this list to update a field, so i click on a button and open a table, update a record and then close it to return to the form.

the List does not update unless I close the form and re-open it again.

Is there a property that automatically updates the list on exiting the query / table you are updating?

Thanks in advance

Hiten

View 2 Replies View Related

Forms :: Requery Moves The Record Back To 1st Record

Sep 2, 2013

I have a form which has 3 subforms based on a table with a combo box. When I select value from the combo box the data on the subform changes accordingly using the 'Requery'. However, they also show the record from the 1st value of the combo box. Is there a way I can get this solved?

View 1 Replies View Related

Requery Form With Previous Conditions

Feb 28, 2005

It's easiest if I take you through step by step. I open a form with a list of students and I have to enter the condtion for a Tutor Group (say I type in 13EN). The form then loads up with all students in 13EN. Then I have a 'Add Student' button which loads up a form with an indivudual students information qith a blank record. Then I press a 'Done' button which closes that form and requeries the Student List form.

My problem is when I requery the form I have to re-enter the condition for 'Tutor Group' i.e. I have to type it in again. Is there any way I can refresh the data from the conditions I have already entered (i.e. for the Tutor group, 13EN) without having to type it in again?

Thanks

View 2 Replies View Related

Forms :: How To Auto Enter Date Of Previous Record Into New Record

Aug 26, 2013

I need to know how to auto enter the date of the previous record into a new record. I have this db for my vehicle log sheets and I submit monthly a claim for the business km from my company. I usually cant remember the date of the previous claim and have to scroll back until I find the field with a date. It will be useful if the date was copied into every new record until I edit the date when I submit the claim. What I ask is during the new month all the dates will be the same until I submit the claim. I do not know how to do this, and yes I have done a search.

View 3 Replies View Related

Forms :: Requery Subform After Deleting A Record

Nov 8, 2014

I'm trying to execute some lines of code right after deleting a record in a subform, with a right click on the row I want to delete (the idea is that if a record is deleted the other ones should be updated by module1.tblUpdateLatestDocuments).

I've tried putting this code into the events On Delete and After Del Confirm of the subform, none of that worked.

Code:
Option Compare Database
Private Sub Form_AfterDelConfirm(Status As Integer)
Call Module1.tblUpdateLatestDocuments
Me.Requery
End Sub

Private Sub Form_Delete(Cancel As Integer)
Call Module1.tblUpdateLatestDocuments
Me.Requery
End Sub

Aren't there any events that I could use right AFTER the record has been deleted?

View 10 Replies View Related

Forms :: How To Put Cursor On Newly Created Record After Requery

Apr 14, 2015

I launch a 'CreateNewRecords' form from a 'MainForm' form. When the 'CreateNewRecords' form closes, the new record is visible on 'Main Form'.The underlying query is unsorted, so this code in the AfterUpdate event of 'CreateNewRecords' puts the cursor on the last record displayed on 'MainForm', which is the newly created record:

Forms!frmMainForm.Requery
With Forms!frmMainForm.RecordsetClone
.MoveLast
Forms!frmMainForm.Bookmark = .Bookmark
End With

However, I intend to sort the underlying query, which means that a newly created record may appear in the middle of the records displayed on 'MainForm'.

What I want to have happen is that after a new record is created by 'CreateNewRecords', the underlying query is requeried so that all current records are displayed on 'MainForm' but also that the cursor rests on the newly created record (rather than default to the first record).

View 7 Replies View Related

Forms :: Create New Record In Form - How To Requery Subform To Link Properly

Apr 2, 2013

I have a form (frmAddManifest) with a subform (subfrmManifestTransporters).

When creating a new record, I can enter data into frmAddManifest, but the subform doesn't update to link with the record - I presume it's because the record from the main form hasn't been completed yet.

Is there a way to requery the form and/or subform so it stays on the record I was working on, and link the subform properly?

View 4 Replies View Related

Forms :: Copy From Previous Record?

Jun 2, 2015

I found and pasted some code which copies records from the previous record on the form. Seems to work well, but I was wondering if there is an issue with the copying of the first field which is a combo box?

View 10 Replies View Related

General :: Return Date Of Previous Day Of Week

Apr 8, 2014

I would like a field's default value to return the date of the previous Monday.

For example:
Now = Tuesday, 08-Apr-14
Return Monday, 07-Apr-14

Further example:
Now = Saturday, 12-Apr-14
Return Monday, 07-Apr-14

View 6 Replies View Related

Forms :: Insert Previous Balance Into New Record

Jan 2, 2014

i am using this query to insert the previouse balance into arrears as shown in the figure. it will insert some record correct and some are not correct.

SELECT fees.[gr no], sum((Admission+Registration+Fees.Tuition+[Fine]+Fees.Transport+[Exam]+[Misc])-Fees.Paid) AS bala
FROM fees
WHERE fees.balance<=0 and [gr no]=[gr no]
GROUP BY [gr no];

View 2 Replies View Related

Forms :: Return Data Instead Of The Record ID?

Nov 19, 2014

I have a form. That form has a combo box. That combo box is supported by a field in a table called Issues. That field is a Lookup field to another table called Contact List.

So my form combo box is populated via field in a table that references another table.

This works fine - and I can drop down and pick a person etc. Email address show up.

The form field is bound to column 1.

The issue:

I want to send an email to the person as selected by the combo box.

This too works, but the email TO: field contains the Record Number, not the text of the field.? How do I get the text of the combo box - which I can see, to appear in the TO field.

I am using a Dlookup:

=DLookUp("[MCCS Managers]","Issues","[ID]=" & Nz([ID],0))

this returns a ' 1 ' which is the record ID number from the Issues table.

MCCS Managers is the field name, Issues is the table, ID of course...

To be redundant, this cascaded field lookup works fine in the form. But my DLookup returns a ' 1 '. (the ID column, not the 'text' column.)

how do I get the text column to return?

View 7 Replies View Related

Error '2118' You Must Save The Current Field Before You Run The 'Requery' Action

Oct 11, 2007

I have a Contacts form which has a Calls sub-form which itself has a Subjects sub-form. From the Contacts form the user can click a button which writes a pro-forma letter from a selection. The application then updates the Call & allows the user to select the Subject(s) from the Subjects available (drop-down menu). If the user wants to write a second letter immediately, I get the above message. If they do anything else first, they are OK.
I have tried refreshing the Contacts form & each of the others at various points in the process, explictly saving the record (caused another error) etc. without success.
Can you help?

View 3 Replies View Related

Forms :: Autoupdate Textbox Based On Previous Record

Jun 17, 2013

I am creating a database for an annual golf tournament. Part of this is to allocate players to play off together at certain times.

I have a form bound to a table called tblteeofftimes. This form has five fields (continuous form) - four of which are comboboxes whereby user selects each player for the record (who will play together). The other textbox has the tee off time. the first tee off time will be allocated by user eg 7:00 am.

My problem is I need to update each ensuing record with a new time slot at 7 minute intervals. Rather than have the user populate the form themselves I would prefer this be done authomatically as the user moves onto the next record.

View 12 Replies View Related







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