• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1708
  • Last Modified:

how to add a combo box in a navigation form header Access 2013 & 2010

Hi guys,

I'm creating a navigation form in access and I'm trying to add a combo box in the header of the form to search for records in a subform which is in a database sheet format. For example, I should be able to type or select the name of an employee and take me to that record in the database sheet form which is a subform in the navigation form.

Also, In the subform in the navigation form I would like to click on the name of the employee and be able to open the form where all the detail information of this employee is.

I know that to do these two things I have to write a code or create macros but I tried everything and I can't figure it out!! Can you give me a hand?

I would appreciate!!!

  • 5
1 Solution
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
You can filter data in your datasheet like this:

In the AfterUpdate event of your combo, do something like this:

Me.YourDataSheetSubformCONTROL.Form.Recordsouce = "SELECT * FROM YourTable WHERE YourEmployeeField='" & Me.YourCombo.Column(0) & "'"

Obviously you'd have to change the names of the tables, fields and controls to match your project.

Also be aware of the "YourDataSheetSubformCONTROL". This is the name of the Subform CONTROL on the main form, and may or may not be named the same as the form you're using as a Subform.

To open "the form" where all the detailed employee info is:

On the Click or DoubleClick event of your datasheet do something like this:

DoCmd.OpenForm "YourDetailForm", , , "YourEmployeeIDField=" & Me.EmployeeIDControl

Again, you'd have to change that to reflect the table, field and control names in your project.
hugonietoAuthor Commented:

Thanks a lot for the help!! I tried what you suggested and non worked...

For the filter or search part I tried what you said and when I select a name from the combo box and enter it and I just get a blank page inside the subform.... it doesn't take me to that record I selected even tough is in there. When I clear the combo box or click on the tab in the navigation form it goes back to showing all the records in the subform. Do you have any idea of what is going wrong or what I'm missing?

For the other part... I had to create a macro in the for subform so it could open the detail form with the record I click on... it works now!!

<?xml version="1.0" encoding="UTF-16" standalone="no"?>
<UserInterfaceMacros xmlns="http://schemas.microsoft.com/office/accessservices/2009/11/application"><UserInterfaceMacro For="txtID" Event="OnClick"><Statements><ConditionalBlock><If><Condition>[Form].[Dirty]</Condition><Statements><Action Collapsed="true" Name="SaveRecord"/></Statements></If></ConditionalBlock><ConditionalBlock><If><Condition>IsNull([ID])</Condition><Statements><Comment>Open the form to a new record if the current ID is Null</Comment><Action Collapsed="true" Name="OpenForm"><Argument Name="FormName">OrderDetail</Argument><Argument Name="DataMode">Add</Argument><Argument Name="WindowMode">Dialog</Argument></Action><Action Collapsed="true" Name="Requery"/></Statements></If><Else><Statements><Comment>Use a TempVar to pass a filter to the OpenForm action</Comment><Action Collapsed="true" Name="SetTempVar"><Argument Name="Name">OrderDetail_ID</Argument><Argument Name="Expression">[ID]</Argument></Action><Action Collapsed="true" Name="OpenForm"><Argument Name="FormName">OrderDetail</Argument><Argument Name="WhereCondition">[ID]=[TempVars]![OrderDetail_ID]</Argument><Argument Name="DataMode">Edit</Argument><Argument Name="WindowMode">Dialog</Argument></Action><Action Collapsed="true" Name="RemoveTempVar"><Argument Name="Name">OrderDetail_ID</Argument></Action><Action Name="RefreshRecord"/></Statements></Else></ConditionalBlock></Statements><Sub Name="ErrorHandler"><Statements><Action Collapsed="true" Name="MessageBox"><Argument Name="Message">=[MacroError].[Description]</Argument></Action></Statements></Sub></UserInterfaceMacro></UserInterfaceMacros>

Open in new window

hugonietoAuthor Commented:
Sorry about the code below the thanks word... That was a mistake! just ignore it!!
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

hugonietoAuthor Commented:
I found an article which does exactly what I want to do!!!! but It just doesn't work for me!!!! the only thing Im replacing is the name "Company" to the name of my field I want to search for which is by the name of the employee.

What am I doing wrong!!


Also, when I tried to set the LimitToList property to No on my combo box I get the error on this picture!! any idea how to fix it?  


hugonietoAuthor Commented:
I found out the solution for my problem. I had to look a similar access form and I dig into the sections I wanted in my forms...... I found out the macros that did this functions I wanted. I just had to modify these macros and implement them in my forms.

hugonietoAuthor Commented:
I found the solution
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Easily Design & Build Your Next Website

Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.

  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now