SOLVED

Search records by a single field

Copper Contributor

Hello

 

Is there a possibility of searching through records using only one specific field?

Among many others, I have the following 2 fields that are causing me problems:

  • Order ID (with primary key)
  • Order Code
  • Quantity

Order Code occurs several times for different orders of the same series (same Code, different Order ID). Then I need to display all orders with the same Order Code (and different Order IDs). From that list of orders I want to display the order I chose by clicking a button (OpenForm > FindRecord), where the "Find What" parameter is that specific Order ID.

So far so good, but this is where problems start for me. I'll explain on a specific example:

I want to display a record with Order ID = "100", however every now and then I have a different record with Quantity = "100" and that search function will display a record with Quantity = "100" instead of Order ID = "100".

 

So here's the question - is it possible to force FindRecord function to ONLY search inside Order ID field and ignore all other fields on the record?

 

 

Thanks

2 Replies
best response confirmed by KakovostMDM (Copper Contributor)
Solution

Hi,

 

In theory you should be able to set the focus to the ID field and set the OnlyCurrentField parameter of the FindRecord method to True.  As that would be too unreliable for me, I wouldn't use that but sth like:

 

Docmd.OpenForm "YourForm", , , "[Order Id]=" & YourSearchReference

 

or if you really want to see all records in the form and only go to the desired record:

 

Docmd.OpenForm "YourForm"

Forms!YourForm.Recordset.FindFirst "[Order Id] = " & YourSearchReference

 

Servus
Karl
Access News
Access DevCon

@Karl Donaubauer Thanks a lot, it works perfectly!

1 best response

Accepted Solutions
best response confirmed by KakovostMDM (Copper Contributor)
Solution

Hi,

 

In theory you should be able to set the focus to the ID field and set the OnlyCurrentField parameter of the FindRecord method to True.  As that would be too unreliable for me, I wouldn't use that but sth like:

 

Docmd.OpenForm "YourForm", , , "[Order Id]=" & YourSearchReference

 

or if you really want to see all records in the form and only go to the desired record:

 

Docmd.OpenForm "YourForm"

Forms!YourForm.Recordset.FindFirst "[Order Id] = " & YourSearchReference

 

Servus
Karl
Access News
Access DevCon

View solution in original post