Set value in second combo box based on first combo box

  • Thread starter Thread starter Paul R in Oregon
  • Start date Start date
P

Paul R in Oregon

frmChooseIssuesDialog has two combo boxes--cboFirstIssue and
cboLastIssue

When user selects issue using cboFirstIssue, I'd like cboLastIssue to
get the same value if it has no value.

Also, if value in cboLastIssue is less than value in cboFirstIssue, I'd
like to display message box and not allow choice.

I'm doing this for a friend and it's been too long since I did these
things to remember how to even get started on this kind of deal. My
brain is going........
 
Paul said:
frmChooseIssuesDialog has two combo boxes--cboFirstIssue and
cboLastIssue

When user selects issue using cboFirstIssue, I'd like cboLastIssue to
get the same value if it has no value.

Also, if value in cboLastIssue is less than value in cboFirstIssue, I'd
like to display message box and not allow choice.

I'm doing this for a friend and it's been too long since I did these
things to remember how to even get started on this kind of deal. My
brain is going........


I think you can use the first issue combo box's AfterUpdate
event to set the last combo box's value:
If IsNull(Me.cboLastIssue) Then
Me.cboLastIssue = Me.cboFirstIssue
End If

Use last issue combo box's BeforeUpdate event to check if
it's an illegal selection:
If Not IsNull(Me.cboFirstIssue) Then
If Me.cboLastIssue < Me.cboFirstIssue Then
Beep
MsgBox "invalid selection"
End If
End If
While this should do what you asked, you might be able to
avoid the problem by using a criteria in the last issue
combo box's RowSource query so that it only has acceptable
values in its list. Then only code that would be needed is
for the first issue combo box's AfterUpdate event to Requery
the last issue combo box.
 
Back
Top