ComboBox Lookup Displays Value Before a Selection Is Made

G

Guest

I have a form that allows a user to select a value in either cboReportNum or
cboReportName that information in the subform is based on. WHen wither a
number or name is chosed, the other cboBox autoupdates to the corresponding
value.

When the form first opens, information is contained in the subform from the
first record in the table. Is there any way to keep the subform values blank
until something is chosen from the box?

Private Sub cboReportNum_Exit(Cancel As Integer)
'Automatically updates report name when a report number is entered
Dim intIndex As Integer

If cboReportNum <> "" Then
If cboReportNum.ListIndex <> cboReportName.ListIndex Then
'eliminates endless focus loop that occurs if already the same

intIndex = cboReportNum.ListIndex
cboReportName.SetFocus
cboReportName = cboReportName.Column(BoundColumn, intIndex)

'Display the maintenance information based on the selected report

Set rs = Me.Recordset.Clone
rs.FindFirst "[REPORT_ID] = " & Str(Me![cboReportName])
Me.Bookmark = rs.Bookmark

End If
End If
End Sub

The code is copied below.
 
G

Guest

It is confusing as to what it is you are trying to do here. However, it
sounds as though you have a subform that you would like to be reliant on a
combobox selection. So with that in mind you probably do not want the
subform to be reliant on the parent form data.

It sounds as though currently you have the subform linked to the parent form
data. So simply remove the entries in the subform control's [Link Child
Field] and [Link Master Field].

Then set up a method of obtaining the value from the combobox (i.e. using
the AfterUpdate() event) and applying the subform's filter to the selected
criteria.

I believe this will get you where you want to be!

Best of Luck!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top