473,387 Members | 1,785 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,387 software developers and data experts.

Combo box to search on TWO fields on a form (Access 2K)

I have a form is based has a table with a dual primary key comprised of a Project ID# and a Department name.

I created a combo box to search the form for a specific record - so I might be looking for record “3-Sales” but if there is a “3-Audit” it will stop at “3-Audit” because of this code:

++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++
Private Sub cboLookUp_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[AAID] = " & Str(Me![cboLookUp])
Me.Bookmark = rs.Bookmark
End Sub
++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++

so how do I rewrite have it search for AAID and DepartmentName?
Apr 10 '07 #1
3 1735
ADezii
8,834 Expert 8TB
I have a form is based has a table with a dual primary key comprised of a Project ID# and a Department name.

I created a combo box to search the form for a specific record - so I might be looking for record “3-Sales” but if there is a “3-Audit” it will stop at “3-Audit” because of this code:

++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++
Private Sub cboLookUp_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[AAID] = " & Str(Me![cboLookUp])
Me.Bookmark = rs.Bookmark
End Sub
++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++

so how do I rewrite have it search for AAID and DepartmentName?
Assumptions:
  1. [AAID] is a Numeric Field [LONG]
  2. [DepartmentName] is a String Field
  3. Combo Box Name is cboLookUp
  4. cboLookup contains 2 Columns (AAID, and DepartmentName)
  5. [AAID] and [DepartmentName] make up the Composite, Primary Key
  6. Code is executed in the AfterUpdate() Event of cboLookup
Expand|Select|Wrap|Line Numbers
  1. Private Sub cboLookUp_AfterUpdate()
  2. Dim intAAID As Integer, strDeptName As String
  3.  
  4. intAAID = Me![cboLookUp].Column(0)
  5. strDeptName = Me![cboLookUp].Column(1)
  6.  
  7. Dim rs As DAO.Recordset
  8. Set rs = Me.Recordset.Clone
  9.  
  10. rs.FindFirst "[AAID]=" & Me![cboLookUp].Column(0) & " AND [DepartmentName]='" & _
  11.                          Me![cboLookUp].Column(1) & "'"
  12.  
  13. If rs.NoMatch Then
  14.   Exit Sub
  15. Else    'got us a match
  16.   Me.Bookmark = rs.Bookmark
  17. End If
  18.  
  19. rs.Close
  20. End Sub
Apr 10 '07 #2
Bullseye - works perfect - thank you for your effort!
Apr 11 '07 #3
ADezii
8,834 Expert 8TB
Bullseye - works perfect - thank you for your effort!
You're welcome.
Apr 11 '07 #4

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

Similar topics

1
by: Anonymous | last post by:
Quick question - I have a form with with many fields on it. I have three combo boxes that are used as search engines (Last Name, City, State). For example, when I open the form, all three search...
1
by: Paolo | last post by:
I would like some help on the use of combo boxes. I have created a form and named it Customers. This form's record source is a table, also named Customer. I would now like to add an unbound combo...
3
by: NB | last post by:
Let's say in the product table I have around 50,000 products (well, infact it has now about 2000 only, but it's growing very fast, hence the question here) In the order form, users will select...
5
by: Dalan | last post by:
I have been searching the archives in an effort to discover how to derive a dual use of a single combo box - so far no go. I found the piece below which pretty much represents the usage. To...
5
by: William Bradley | last post by:
I have a need to construct a combo box that will fill in two fields, on a form,from a single table. The table: "IndexNo", "Product","Supplier","Address" etc. What I would like to do is be...
10
by: motessa | last post by:
Hello All, I am new to Access and have been looking for answers to my problem on the internet and have not found it yet. I hope someone can give me a hint. Thanks so much. I have a form...
2
by: Damon Cherne | last post by:
Here is my issue. I have created a form called “Search” that has several unbound combo boxes, one for each of the attribute that match a column in the Table . Each combo box has input from a...
1
by: Bill | last post by:
Problem: Combo box data disappears from view when a requery is done See "Background" below for details on tables, forms & controls On a form, I want to use the setting of bound combo box C1...
4
by: Dave | last post by:
I wasn't sure how to search for previous posts about this, it felt real specific. Ok so here's the database & problem: I have 4 combo boxes: cboServer, cboPolicy, cboDB, and cboApplication. ...
2
by: biganthony via AccessMonster.com | last post by:
Hi, I decided to install Office 2003 Service Pack 3 on my home computer to test (in full knowledge that there may be some issues with it). After installation, I have noticed that with a small...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...

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.