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
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.
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
I would like to be able to switch between these two forms and the form automatically set focus to the record that I was on the form prior. Meaning if I am on record 3 on Form A and navigate to Form B, I would like to automatically set focus to record 3. Is this possible?
A possible issue after this gets sorted out is what happens if with the same scenario above record 3 does not exits? is it possible in that instance to simply requery the form?
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?
When I add a record in the subform and then move to the next record whilst still in the subform, the main form jumps back to its first record? I then have to move back to the right record in the main form to update the next record in the subform.
I want to move to the next record in the subform without affecting the main form.
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?
I have a subform with records of call details (date, time, subject) - the date and time are autogenerated and subject is a text field. After entering text in the subject field and then clicking on the close button in the main form, or clicking anywhere else in the main form, the record is saved to the table. However, if I enter text in the subject field and then move up to view previous records (within the subform) and then click the close button in the main form the record is not saved in the table. How can I either save the record before allowing the user to move to another record within the subform or before exiting the subform set the focus to the new record so that it will be saved on exit?
I need SQL Statements to use in VBS code for microsoft access that will move the current record being displyed on the form (lets say the table name is called 'old') to another table called 'new'. Also the record that is being moved to the new table needs to be deleted from the 'old table'. All of this needs to be done with the click of the mouse on the 'old' form.
Hi - My first time here, and I am fairly new to Access, but getting on OK. So as ever, be kind.
I have spent several hours reading this forum and learnt a few things, and been completely confused by other things. My Job is IT but Software, Networks etc configuration rather than programming.
I am trying to help a charity out by building a database for their Sportsday.
I have a Parent Form Called Team, with Sub forms in Tabs for Team Details, Competitors etc.
In the Team Details, They can Choose the Hospital and Team Manager.
I have a Combo box with a lookup query, which looks up the Manager. However, rather than just display a last name, I have changed the SQL behind the (Properties - Data - Row Source), so that I get a concatenation of the Surname and First name:
SELECT tblCompetitor.CompetitorID, [surname] & " " & [Firstname] AS Fullname FROM tblCompetitor ORDER BY tblCompetitor.Surname;
All Works fine
I know I can use a "Not In the List" command, but initially they want a button to open an Add Manager Form.
No Problem except when I close and try to enter the New Managers Details in the Combo Box and requery.
I have a button to close the Add Manager Form and requery the Manager Combo in the originating Form
Private Sub CloseCompetitorsEditPopUp_Click() On Error GoTo Err_CloseCompetitorsEditPopUp_Click
Forms![frmTeam]![ChildTransplantTeam].Form![Manager] = Me.CompetitorID (the Manager field is a lookup from the Competitor table) Forms![frmTeam]![ChildTransplantTeam].Form![Manager].Requery DoCmd.Close
This code works fine if I just use the Managers Surname as the Data Field, but leaves a blank field in the Combo Box if I am displaying concatenation, until I do some sort of refresh.
Any Ideas if I can do this seamlesly as it is driving me potty.
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.
Hi. First off I want to say that these forums are a gold mine. You all do a great job. Keep it up!
I work at a University and keep a database of students. On the main form for the student, you select their name from a combo box and the whole form refreshes to show the data for your selection. There are four subforms that keep track of things like a questionnaire, career center visits, etc. The problem I am having is with the Career Center visits.
There is a button that allows you to make an entry into a log when they come into the career center. Clicking on it opens up a small window where you can put notes and with whom they spoke while they were here. Upon closing the window, it adds the entry to the log for that particular student. That all works great. Each student has their own log...all is good.
However, upon closing the window, the main form jumps back to the first student in the list. The entry is added to the correct student, but you must find the student from the combo box in order to see it. It is just annoying to have to do it and I would like to fix it. Can't figure out why it is doing it, though.
Any ideas? I would like it to add the entry to the student, and stay on their record.
I have a Form [customers], which contains a tabbed control and within one of the tabs I have a subform [Loans]. The Loans form is a "display only" form which lists clients loans. The loans can be updated or added to by a popup form which acts as a loan calculator. The "After Update" event of the popup form requeries the [customers] form when the amended loan record is entered via the selection of a new record on the popup. This has the effect of displaying the changed loans on the underlying [loans] form.
This works OK except that the record being displayed on the customers form immediately jumps to the first record in the customers table.
Has anybody any thoughts on why it would jump records after the requery and how I could stop it.
The requery code is as follows
Private Sub Form_AfterUpdate() Forms![customers].Requery End Sub
This database will show the asset, where it is, what it is and who its with . It will display this on a form.
When this asset gets given to someone else i want a button on the form which displays the assets current data to be clicked and for that info to be moved from the asset current table into the asset history table.
Can anyone tell me how do i move to the previous record in the database using asp. i have tried the following Code:rs.moveprevrs.moveprevious hint's will also help
Here is the code I have to Update a table tblExternalIncomeSchedule
It works fine and updates the table for the first record.
How do I move to the next record StartYear 6 thru EndYear 10 and write that data to the same table without overwriting the data from the first record?
It should add 5 more records to the table
Yr 6 2000 Yr 7 2000 (since inflation = 0) Yr 8 2000 (since inflation = 0) Yr 9 2000 (since inflation = 0) Yr 10 2000 (since inflation = 0)
Code: Function FillExternalIncomeSchedule(nClientID As Long, nProposalId As Integer, nProposalYears As Integer, nRetireAge As Integer) Dim rst As Recordset Dim qdf As QueryDef Set qdf = CurrentDb.CreateQueryDef("", "DELETE * FROM [tblExternalIncomeSchedule] WHERE [ProposalID] = " & nProposalId) qdf.Execute
I have looked for ages for a solution to this and have not yet found one to suit me so here I am.
I am creating an Access 97 db in which I have a form (section1) which shows its records in datasheet format(results from a query). On this form is a button which opens another form (fileViewNewSec1) where the user can input the data for a new record. In the closeEvent() part of this form I have put:
=[Forms]![section1].[Requery]
This successfully refreshes the form and the new record can be found. However, there are many records in this database and it would be nice if once the form (section1) has been refreshed that it would focus on the newly created record. I am not sure if anyone can help me with this.
The records are sorted by "fileRef" and therefore the newly created record is not placed at the bottom of the records. They do however have an auto number primary key, I am not sure this will be useful but they you go.
I have a sub form on a tabbed control. In the subform I have some calculated controls and I make them recalc when ever data in other fields change bu entering a recalc cmd in the update event of the required fields. That is all fine but the problem is that the forms focus moves to the first record and I need it to stay on the active record.
I have tried requery, recalc and refresh methods and they all do the same thing.
All I need to do is up date the calculated controls each time a field is updated and stay on the same form but it's eluding me.
When I click the button "open new order" after that my form it's open with new id and it's ok, but when I push the key "F5" then Ms Access goes to another record (no new record). Why is that?
Ok i'm opening a form with the intention of grabbing the last reference number and adding one then moving to a new record.
However the form opens on the first record. Here is my code.
Private Sub Form_Open(Cancel As Integer) Dim lastbookref As String Dim expans As String Dim Newbookref As Integer Form_frmbooking.RecordSource = "SELECT tblbooking.Bookingno, tblbooking.Clientno, tblbooking.Sampledate, tblbooking.Sampleref, tblbooking.[Sample place], tblbooking.Recieveddate, tblbooking.Recievedby FROM tblbooking WHERE (((tblbooking.Bookingno) Like """ & Left(Form_frmClient.Clientname, 3) & "*""));"
If Form_frmbooking.Recordset.BOF = True Then Form_frmbooking.Bookingno = Left(Form_frmClient.Clientname, 3) & "/00/0001" Else Form_frmbooking.Recordset.MoveLast lastbookref = Form_frmbooking.Bookingno DoCmd.GoToRecord , , acNewRec
Newbookref = Val(Right(lastbookref, 4)) + 1 Select Case Newbookref Case Is < 10 expans = "000" & Newbookref Case Is < 100 expans = "00" & Newbookref Case Is < 1000 expans = "0" & Newbookref End Select Form_frmbooking.Bookingno = Left(Form_frmClient.Clientname, 3) & "/00/" & expans End If End Sub
Anyone have any idea why this is not moving the new record.
Even more bizarrely the new booking reference is inserted into the new record....its just that the form opens up on the first record.
I need to be able to move 2 fields from the previous record to the next record. Does anyone know how to do this?
What I am doing is the following:
I have a table with 3 fields. I am using a form to enter the information. Two of the fields on the form will be information from the previous record. How can I bring that information forward to automatically be on the form and in the table?
Hi, found this forum looking for an answer to this question. Hope someone can help.
I'm trying to build a database that tracks electronic components. Mostly the database tracks location movements, but also repair issues and other possible changes. I'm thinking the best way is a database that has a record for each move, and any other changes are included in each record.
My question is, is there a way I can easily have the current information be propogated over to a new record, where it could then be modified? Example: I'm looking at a record of an item that was just returned to me. I would like to click a button on the form which would create a new record, then move all currently displayed information into that record.
I have a tabbook on a bound form, and an unbound combobox just before the tabbook. Whenever I tab or enter out of the combobox the form goes to the next record. Is this supposed to happen? If so, how do I stop it.