Opening Form From ComboBox

Graybeard

Registered User.
Local time
Today, 11:19
Joined
Aug 7, 2004
Messages
64
Im not sure if this question is being posted in the right place so please excuse me if it should be posted someplace else. I have combobox on a form based on a select query that allows the user to select the name of any customer in the data base(approximately 400 names). When they select the name I want the record for that customer to open. I really dont want to write 400 select case statements but I am new and that is the is the only code I have learned so far which will open a form based on a selection made in a combo box. I have to believe there is an easier way. Can someone please help?
 
Something akin to this; changing names to match your own controls.

Code:
DoCmd.OpenForm "MyForm", , , "[CustomerID] = " & Me.MyCombo.Column(0), acFormEdit
 
Basically you call the report or form that you want to open within an Event Procedure on the "On Click" property of the combo box.

This calls a report called rep_Rep_Sect_Part_Defect to open in print preview mode
DoCmd.OpenReport "rep_Rep_Sect_Part_Defect", acViewPreviewThis report is based on a query that has a criteria

[Forms]![frm_Reports_Main]![cbo_Sect]

This uses the value in the combo box cbo_Sect on a Form called frm_Reports_Main.

This combo box is the same one that has the On Click Event Procedure
So selecting a value from a combo box opens a report based on the selected value of the combo box

Do same sort of thing with a Form

DoCmd.OpenForm "Frm _Name",acnormal, etc

HTH

Len B
 
Thank you SJ and Colin. I ended up using SJ's method. Seemed simplier and worked perfectly.At the risk of being a pain in the butt, SJ I do have a question. I like to understand and not just copy code. My customerID field which is the bound field is in column 1. I used 0 as you had in your code and it worked. Why the zero when when then bound column is one and why does it work?
 
The first column is referred to as 0. The second 1, etc.

0, with respect to the BoundColumn, is a property value.

If it helps, put the cursor over the relevant control's properties and hit F1 for a more indepth explanation.
 
The column counting starts at zero. Column #1 is Column(0), Column #2 is Column(1), etc.
 

Users who are viewing this thread

Back
Top Bottom