473,402 Members | 2,061 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

Form doesn't change records if record is newly added.

Seth Schrock
2,965 Expert 2GB
I have a problem that if I have a form open and a new record gets added by another user, I have to close my form before I can go to that record. My current setup is that I have a Home form that has a list of the active records and I have my Loan form that has all the details. When I select a record on my Home form, I use the following code to go to the selected record on my Loan form:
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenForm "frmLoans"
  2. DoCmd.SearchForRecord , , acFirst, "LoanID = " & LoanID
This works even if I leave my Loan form open and then go to my Home form and select an already existing loan. However, if I select a loan that was added after the Loan form was opened, the record doesn't move. My thinking is that the new record wasn't part of the query when the form was opened and therefore it doesn't see that record. My idea is to just add Forms!frmLoans.Requery between the above two lines so that the new record is available. However, I think that this will trigger the OnCurrent event to run twice; once for the requery and then again for the .SearchForRecord. Is there a better way to do this? I'm thinking something to do with the recordsource, but not sure what.

I hope I'm clear. It is a bit complicated to explain.
Apr 10 '13 #1
5 1173
TheSmileyCoder
2,322 Expert Mod 2GB
You are correct in your assumptions. While Access will periodically refresh the data collected, it will not collect new records, unless required.

Is there any reason why you don't open the frmLoans as a modal popup with a filter to the specified record? That way you retrieve less data, and the user has to close the form to select a new loan.

You could also use instanced forms if you require the ability to have multiple loans open at a time.
Apr 10 '13 #2
zmbd
5,501 Expert Mod 4TB
The requery will more than likely trigger the on current as Me.Requery essentially reloads the form by re-running the query; thus, your current position is lost will change from where you are to the top of the sort order.
Order of events for database objects (v2010)
And then as you suspect the on current will fire again on the record movement... there's no way around that.
Apr 10 '13 #3
Seth Schrock
2,965 Expert 2GB
@Smiley I don't like having forms filtered on their PK value as it makes it complicated to navigate to another record in the same form. I currently have the filter set to get only the current user's records. This is fine since I can still navigate fairly easily through the records within the filter. However, I might play with instanced forms. I would need to come up with a way to count the number of forms open so that they don't get so many it start to degrade performance though.

@Z I figured that was the case with the Requery. Is there a way to SearchForRecord in Recordsource or something similar?
Apr 10 '13 #4
TheSmileyCoder
2,322 Expert Mod 2GB
@Seth
I thought you were using the main form as a navigation form, and then frm_Loans as a edit/viewing form. Part of the approach of the instancing of forms involve a collection to place the forms in. So its somewhat easy getting a count of the forms open, since you can just count on the collection. There is a method in my crash reporter as well, to count the number of linked "connections" available (applicable if you are using linked tables (Access or SQL))

An easier approach might be to use the recordset of the form, and use the RecordSet.FindNext method, and check to see if RecordSet.NoMatch is true. If so, you can try a requery, and moving to record again.
Apr 11 '13 #5
Seth Schrock
2,965 Expert 2GB
I have used your easier approach for now because I can implement it quickly. When I get more time, I might look into the instanced forms.

You are correct that I was using the main form as a navigation form, but I also have navigation built into the header of the Loan form as well so that they can go to another loan without having to go back to the home form.
Apr 11 '13 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: kindermaxiz | last post by:
hi there i have a mysql table and i want the user to add columns using a php interface and then display the table with the newly added column. I was thinking about putting all the columns...
6
by: Tony Stoker | last post by:
I have a .Net web app that adds a record to a SQL database. After the user adds their record I want to have a link that will link them to their new record! The recordID is a AutoNumber in the...
4
by: David Mitchell | last post by:
I have a form based on a totals query which lists a recordset of peoples name where there is no match with tblrelman. The user then selects from a combo box on the same form the correct name and...
5
by: Xiphias | last post by:
Hi, Can someone help me to create a drop box where I can also add new records? Here is the problem: I m working on a form with a drop box. When I select a '"name" in the drop box the form...
3
by: damezumari | last post by:
I am using WinXP and MS Access 2003. I have a list whose row source is an sql. I insert a new record to the table the sql takes its data from. I requery the list and the new record appears. ...
1
by: mike | last post by:
I have a datagridview control and a button on the windows form. I am adding a new row in button click event. When the number of rows grow, the newly added row will not be visible but a scroll bar...
2
by: Certys | last post by:
Hello, I have a form where I only allow new records to be added. I enable this by setting the form property "Data Entry" to Yes. I want to access other records in the same table- to autofill...
9
by: =?Utf-8?B?UHJhdmlu?= | last post by:
We are using .net Framework 1.1 We are having one page on which we are using this Grid component. From this page we open a popup for adding new record as well as for editing an existing record...
2
nev
by: nev | last post by:
i place values in a new row programatically. it has an auto-increment column. after adding the entries i do... bindingsource.endedit() tableadapter.update(dataset.datatable) the saving process...
1
by: bkberg05 | last post by:
Hi -I have a form which contains a sub-form. The sub-form is tied to the main form by a shared field called Project_ID. The main form has one record per Project. The sub-form has many records per...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.