Combo box required

  • Thread starter BonnieW via AccessMonster.com
  • Start date
B

BonnieW via AccessMonster.com

I have a series of three forms, editing two tables. In the first form, there
is a combo box in which the user selects a place name (where the work was
performed). The user then has two choices (staff effort or volunteer effort)
in button format; they go to different forms.

The place name (combo box) is required in the underlying table, but that
record is not "saved" til about three forms down the road, so we don't hit
an error message til them. Similarly, BeforeUpdate code isn't preventing the
user from moving to the next form, but in case I did something wrong:

Private Sub Form_BeforeUpdate(Cancel As Integer)
If IsNull(Me!Combo25) Then
MsgBox "You simply MUST choose a Natural Area! All the cool kids are
doing it."
Cancel = True
Me!Combo25.SetFocus
End If
End Sub

(I've set the DefaultValue for Combo25 to Null).

The combo box doesn't (I think) lose focus- the next logical step after
choosing a place (or not choosing it, as the unfortunate case may be) is to
hit one of the buttons leading to the next form.

How do I get this combobox to require data?

Thanks in advance!
 
B

BonnieW via AccessMonster.com

Forgot to mention: the combobox is unbound, its rowsource is a query.
 
C

Carl Rapson

BonnieW via AccessMonster.com said:
I have a series of three forms, editing two tables. In the first form,
there
is a combo box in which the user selects a place name (where the work was
performed). The user then has two choices (staff effort or volunteer
effort)
in button format; they go to different forms.

The place name (combo box) is required in the underlying table, but that
record is not "saved" til about three forms down the road, so we don't
hit
an error message til them. Similarly, BeforeUpdate code isn't preventing
the
user from moving to the next form, but in case I did something wrong:

Private Sub Form_BeforeUpdate(Cancel As Integer)
If IsNull(Me!Combo25) Then
MsgBox "You simply MUST choose a Natural Area! All the cool kids
are
doing it."
Cancel = True
Me!Combo25.SetFocus
End If
End Sub

(I've set the DefaultValue for Combo25 to Null).

The combo box doesn't (I think) lose focus- the next logical step after
choosing a place (or not choosing it, as the unfortunate case may be) is
to
hit one of the buttons leading to the next form.

How do I get this combobox to require data?

Thanks in advance!
 
B

BonnieW via AccessMonster.com

I actually managed to sort it out with an if...then...else statement in the
onclick of the buttons in question. Thanks!
 

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