Link to home
Start Free TrialLog in
Avatar of cssc1
cssc1Flag for United States of America

asked on

How to add a combo box on a form so it controls the other data on the form?

The images attached (Form-1 and Form-2)give an explanation of the problem and what I am trying to accomplish.
The Incident Title on the “Condition” form is a working example of what I am trying to accomplish on the Causal form.
RC.zip
Form-1.jpg
Form-2.jpg
Avatar of Scott McDaniel (EE MVE )
Scott McDaniel (EE MVE )
Flag of United States of America image

So you want to be able to select an Incident Title and have all the related information for that Incident displayed on the form?

If so, it looks like you could just find the related Event record, and set the Form's Bookmark to that, which should then show all the related records in the subforms. To do that:

Dim rst As DAO.Recordset
Set rst = Me.RecordsetClone

rst.FindFirst "Incident_ID=" & Me.YourIncidentTitleCombo.Column(0)
If Not rst.NoMatch Then
  Me.Bookmark = rst.Bookmark
Else
  Msgbox "Incident not found"
End If

You'd add that in the AfterUpdate event of the Incident combo. I'd suspect the RowSource of the Incident combo would be the same as the Incident combo on the Conditions_1of3_frm.
Avatar of cssc1

ASKER

yes, that is exactly what I am trying to do.

I added your code to the afterupdate and now I am getting an error and nothing is in the combo box.

I don't know what to do at this point.

Please see attached images and db
error-3077.jpg
error--.jpg
RC-2.zip
RC-2.accdb
Is Incident_ID a Text value, or a Numeric value?

If it's Text:

rst.FindFirst "Incident_ID='" & Me.Combo26.Column(0) & "'"

Also, what's the RowSource for Combo26?
Avatar of cssc1

ASKER

Incident_ID is a Numeric value.

I think the Row Source is the table "1-Incident-tbl" and the field to populate the Combo 26 is "INCIDENT TITLE:".

I hope this helps, thank you
ASKER CERTIFIED SOLUTION
Avatar of Scott McDaniel (EE MVE )
Scott McDaniel (EE MVE )
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of cssc1

ASKER

more errors.

I am not sure I am doing this part correctly "and post the RowSource of the query here".

Also, what query di I post and where is it posted?

see attached image
error--3.jpg