ADezii 8,834
Recognized Expert Expert - Use the FindRecord Method of the DoCmd Object (least efficient) - The simplest approach for finding a specific Record is to create an Event Procedure for the Combo Box that mirrors each step of the generic Find process.
- Private Sub cboFind_AfterUpdate()
-
Application.Echo False
-
-
Me![EmployeeID].SetFocus
-
-
DoCmd.FindRecord cboFind
-
-
cboFind.SetFocus
-
-
Application.Echo True
-
End Sub
-
- Using the ApplyFilter Method of the DoCmd Object (more efficient) - A more efficient approach is to use a Filter to select a Record directly from the Form's Recordset. The Applyfilter method lets you apply a Filter to a Table, Form, or Report to restrict or sort the Records in the Table or in the underlying Recordset of the Form or Report. You can specify a saved Query as the Filter using the filtername Argument, or you can enter a SQL Where Clause in the wherecondition Argument.
- Private Sub cboFind_AfterUpdate()
-
Dim strSQL As String
-
-
strSQL = "[EmployeeID] = " & Me![cboFind]
-
-
DoCmd.ApplyFilter wherecondition:= strSQL
-
End Sub
- Using the RecordsetClone (most efficient) - This approach is the most efficient and uses the Form's RecordsetClone to refer to the Form's Recordset.
- Private Sub cboFind_AfterUpdate()
-
Dim strCriteria As String
-
-
Dim rst As DAO.Recordset
-
-
Set rst = Me.RecordsetClone
-
-
-
-
strCriteria = "[EmployeeID] = " & Me![cboFind]
-
-
rst.FindFirst strCriteria
-
-
Me.Bookmark = rst.Bookmark
-
End Sub
7 79810 dima69 181
Recognized Expert New Member - Use the FindRecord Method of the DoCmd Object (least efficient) - The simplest approach for finding a specific Record is to create an Event Procedure for the Combo Box that mirrors each step of the generic Find process.
- Private Sub cboFind_AfterUpdate()
-
Application.Echo False
-
-
Me![EmployeeID].SetFocus
-
-
DoCmd.FindRecord cboFind
-
-
cboFind.SetFocus
-
-
Application.Echo True
-
End Sub
-
- Using the ApplyFilter Method of the DoCmd Object (more efficient) - A more efficient approach is to use a Filter to select a Record directly from the Form's Recordset. The Applyfilter method lets you apply a Filter to a Table, Form, or Report to restrict or sort the Records in the Table or in the underlying Recordset of the Form or Report. You can specify a saved Query as the Filter using the filtername Argument, or you can enter a SQL Where Clause in the wherecondition Argument.
- Private Sub cboFind_AfterUpdate()
-
Dim strSQL As String
-
-
strSQL = "[EmployeeID] = " & Me![cboFind]
-
-
DoCmd.ApplyFilter wherecondition:= strSQL
-
End Sub
- Using the RecordsetClone (most efficient) - This approach is the most efficient and uses the Form's RecordsetClone to refer to the Form's Recordset.
- Private Sub cboFind_AfterUpdate()
-
Dim strCriteria As String
-
-
Dim rst As DAO.Recordset
-
-
Set rst = Me.RecordsetClone
-
-
-
-
strCriteria = "[EmployeeID] = " & Me![cboFind]
-
-
rst.FindFirst strCriteria
-
-
Me.Bookmark = rst.Bookmark
-
End Sub
A little comment to the last method.
Setting the bookmark - Me.Bookmark = rst.Bookmark
when the form record is already the one we are looking for may cause Access to crash.
So I would add the check like - If Me![EmployeeID] <> Me![cboFind] Then ...
ADezii 8,834
Recognized Expert Expert
A little comment to the last method.
Setting the bookmark - Me.Bookmark = rst.Bookmark
when the form record is already the one we are looking for may cause Access to crash.
So I would add the check like - If Me![EmployeeID] <> Me![cboFind] Then ...
Excellant point dima69 - I was totally unaware of this, but will definately keep it in mind now! Thanks.
Hi,
I was looking at your 3rd example and it is similar to what I'm using for my forms. But I have a problem, If one person opens form A and select one of the record from the list it works fine. Now at the same time if second person open the same form A from the same copy of MSAccess the first form A starts pointing at the new record also and save changes to the newly selected record. How can I prevent this happen, so that each instance of form A points to its selected record?
Thanks
Excellant point dima69 - I was totally unaware of this, but will definately keep it in mind now! Thanks.
Hi,
I was looking at your 3rd example and it is similar to what I'm using for my forms. But I have a problem, If one person opens form A and select one of the record from the list it works fine. Now at the same time if second person open the same form A from the same copy of MSAccess the first form A starts pointing at the new record also and save changes to the newly selected record. How can I prevent this happen, so that each instance of form A points to its selected record?
I'm using MSSQL ODBC linked tables inside MS Access.
Thanks
ADezii 8,834
Recognized Expert Expert
Hi,
I was looking at your 3rd example and it is similar to what I'm using for my forms. But I have a problem, If one person opens form A and select one of the record from the list it works fine. Now at the same time if second person open the same form A from the same copy of MSAccess the first form A starts pointing at the new record also and save changes to the newly selected record. How can I prevent this happen, so that each instance of form A points to its selected record?
I'm using MSSQL ODBC linked tables inside MS Access.
Thanks
I imagine that a Client/File Server architecture with multiple Front End Databases linked to a single Back End would solve this problem. Each Front End would now have its own, independent Form A instances, and this type of conflict should not then be a problem.
This looks like something I've been trying to do, but I dont know how to implement it to try it out.
I'm already using the first example, but what I want is a pull down list to select a record. I have that working in a different form, and it's working perfectly, but I cant get it to work on the primary form.
Is it because I'm trying to pull up the record by it's Primary Key, that I've been unsucessful?
Will that third example solve that? If so, how do I implement it? If not, is there a way to do this?
BTW there was an explaination that I tried to use, but it didnt work (I posted to the thread 3/28 or 3/29.
Thanks!!!
Hello. The First solution works for me very well. Thanks for sharing and saving me from long nightmares!!! Great!!!!!
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Ian |
last post by:
I want to open a form at a particular record, but I think I'm running
into problems because the recordsource query is executing
asynchronously.
In the form's open event I use recordsetclone.findfirst to get a
bookmark and then set the form's bookmark to this value. normally that
works fine, but the form I am using has a very large number of records
and isn't being set to the correct record, even though it is found
successfully in the...
|
by: bjaj |
last post by:
Hi
I got a form where I type a number.
After taht I split it in two.
Then I search in a table if there are any record that match the two
numbers and not yet been completed.
The code:
VareVar = Left(Me!VareNr, 8)
MyLen = Len(Me!VareNr) - 8
|
by: DavidB |
last post by:
New to .net....sorry if this seems repetitive
I have a dataset ordered by date (SQLDataAdapter SelectCommand uses
Order By) and want to find a record by a UniqueID(Identity Column).
Then I want to change the position (BindingContext) in the dataset to
have all my bound controls reflect the data in the found record - and
the related records/tables.
Problem is, it appears it can't be done....
The Dataset has to be ordered by the date...
|
by: nkoske |
last post by:
I have a form with a subform in datasheet view and I have a event on
one of the fields in the subform, so that the user can double click it
and go to expanded information based on that field.
I'm using this code:
Private Sub SpecimenNum_DblClick(Cancel As Integer)
DoCmd.OpenForm "RDDevice", , , " = '" & Me! &
"'"
End Sub
|
by: Timbo |
last post by:
Hi there,
I’m not used to working in VB and I think this situation calls for excactly that. I use Access 97 SR-2.
My first table is a table containing all the Tickets I got. The field ”Ticket” is simply a ticket-number.
I’ve made a form in which I am to choose an existing Ticket and write a description for it pluss other things. The description to these Tickets are stored in another table called ”LogBook”. I then made a query on all of...
| |
by: BerkshireGuy |
last post by:
Is there a way to create a shortcut to open a MS Acccess DB and have it
go to a specific record?
In my DB, when a user delegates a record to another users, I currently
send out an email to the personing saying they been delegated to
followup on an item.
I list the reference number, but was thinking that it would be really
cool if I could attach a shortcut in the email that would go to the
record.
|
by: cmp80 |
last post by:
I have a database that I am using to store student data. There are two tables and two forms to display the data:
Tables
tbStudent
tbRE
Forms
fmStudent
fmRE
|
by: cvillav |
last post by:
Hello, I am new to Access and this forums,
I have two tables and two forms to display the data.
Tables
Tbuilding
Tcriteria
Forms
fmbuilding
|
by: Redbeard |
last post by:
I have a button on a popup form that when clicked runs a code to duplicate the current record that I am viewing on my main form. It first asks me to enter a new number (primary key) into a pop-up box and then duplicates the record replacing the primary key with the new number. I use this in cases where the next record only requires a few field changes, so I don’t have to retype the hold record. The problem is that when the code runs to do...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |