If Salesperson not paid then you must choose a salesperson

  • Thread starter Thread starter Dave Elliott
  • Start date Start date
D

Dave Elliott

I have a form that has a salesperson drop down list and a salesperson paid,
true or false on it.
I would like to be able to have it not let or ask me for a salesperson when
I choose to mark the salesperson as paid.
The two controls are Combo187 which has a value of true or false that I
choose when paying a salesperson.
The other control is Combo6 which shows a list of salespersons.
Can I do this ?

Thanks,

Dave
 
Sure. Try using the AfterUpdate event of the Combo6 control to test the
value of Combo6, and then disable the Combo187 control if Combo6 = True
(assuming that Combo6 is using a boolean format):

Private Sub Combo6_AfterUpdate()
Me.Combo187.Enabled = Not Me.Combo6.Value
End Sub

If Combo6 is using a text format then this should work:

Private Sub Combo6_AfterUpdate()
Me.Combo187.Enabled = (Me.Combo6.Value = "False")
End Sub
 
I probably didn't explain, or either I dont understand.

I want the Combo187 which lets you choose either true or false if the
salesperson has been paid or not.
When the answer is true I want it tell me , hey you haven't chosen a
salesperson and not let me proceed without a salesperson being chosen.
The salesperson comes from the control Combo6.

The format of combo187 is True/False
The format of combo6 is blank

Thanks,

Dave
 
Sorry...I did misunderstand!

Assuming that you want to "move" the focus to Combo6 in this instance, I'd
use the form's BeforeUpdate event to trap this error:

Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.Combo187.Value = "True" And _
Len(Me.Combo6.Value & "") = 0 Then
MsgBox "You must select a salesman."
Cancel = True
Me.Combo6.SetFocus
End If
End Sub
 
Is Combo187's bound field a boolean field (Yes/No format)? If yes, then
change the If statement to this:

If Me.Combo187.Value = True And _
IsNull([Combo6]) Then

--
Ken Snell
<MS ACCESS MVP>

Dave Elliott said:
I tried the code, but it did nothing. I tried this code and it didn't work
either.
Both fields are bound controls. Combo187 is bound to Paid Salesman and
Combo6 is bound to Employee.
What else can I try ?

Thanks,
Dave

If Me.Combo187.Value = "True" And _
IsNull([Combo6]) Then
MsgBox "You must select a Sales Person."
Cancel = True
Me.Combo6.SetFocus
End If



Ken Snell said:
Sorry...I did misunderstand!

Assuming that you want to "move" the focus to Combo6 in this instance, I'd
use the form's BeforeUpdate event to trap this error:

Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.Combo187.Value = "True" And _
Len(Me.Combo6.Value & "") = 0 Then
MsgBox "You must select a salesman."
Cancel = True
Me.Combo6.SetFocus
End If
End Sub

--
Ken Snell
<MS ACCESS MVP>


that
 
Thanks Ken, it works good, except that it wont move the focus to Combo6. I
can live with that if I have to.
P.S. It says I must save the field before I can use the goto method.

Thanks,

Dave

Ken Snell said:
Is Combo187's bound field a boolean field (Yes/No format)? If yes, then
change the If statement to this:

If Me.Combo187.Value = True And _
IsNull([Combo6]) Then

--
Ken Snell
<MS ACCESS MVP>

Dave Elliott said:
I tried the code, but it did nothing. I tried this code and it didn't work
either.
Both fields are bound controls. Combo187 is bound to Paid Salesman and
Combo6 is bound to Employee.
What else can I try ?

Thanks,
Dave

If Me.Combo187.Value = "True" And _
IsNull([Combo6]) Then
MsgBox "You must select a Sales Person."
Cancel = True
Me.Combo6.SetFocus
End If



Ken Snell said:
Sorry...I did misunderstand!

Assuming that you want to "move" the focus to Combo6 in this instance, I'd
use the form's BeforeUpdate event to trap this error:

Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.Combo187.Value = "True" And _
Len(Me.Combo6.Value & "") = 0 Then
MsgBox "You must select a salesman."
Cancel = True
Me.Combo6.SetFocus
End If
End Sub

--
Ken Snell
<MS ACCESS MVP>


I probably didn't explain, or either I dont understand.

I want the Combo187 which lets you choose either true or false if the
salesperson has been paid or not.
When the answer is true I want it tell me , hey you haven't chosen a
salesperson and not let me proceed without a salesperson being chosen.
The salesperson comes from the control Combo6.

The format of combo187 is True/False
The format of combo6 is blank

Thanks,

Dave





Sure. Try using the AfterUpdate event of the Combo6 control to
test
the
value of Combo6, and then disable the Combo187 control if Combo6 = True
(assuming that Combo6 is using a boolean format):

Private Sub Combo6_AfterUpdate()
Me.Combo187.Enabled = Not Me.Combo6.Value
End Sub

If Combo6 is using a text format then this should work:

Private Sub Combo6_AfterUpdate()
Me.Combo187.Enabled = (Me.Combo6.Value = "False")
End Sub


--
Ken Snell
<MS ACCESS MVP>

I have a form that has a salesperson drop down list and a salesperson
paid,
true or false on it.
I would like to be able to have it not let or ask me for a salesperson
when
I choose to mark the salesperson as paid.
The two controls are Combo187 which has a value of true or false that
I
choose when paying a salesperson.
The other control is Combo6 which shows a list of salespersons.
Can I do this ?

Thanks,

Dave
 
OK - I'll have to think more about why the setfocus might not work here.
--
Ken Snell
<MS ACCESS MVP>

Dave Elliott said:
No other events are triggered by these controls.
But the code will work like it is without the set focus, they just wont be
able to pay the employee without choosing a salesperson, which is is what I
wanted.

Thanks Again,

Dave
Ken Snell said:
You normally should not have a problem with moving the focus to Combo6 in
this code. Are there other code procedures on other events?
--
Ken Snell
<MS ACCESS MVP>

Dave Elliott said:
Thanks Ken, it works good, except that it wont move the focus to
Combo6.
I
can live with that if I have to.
P.S. It says I must save the field before I can use the goto method.

Thanks,

Dave

Is Combo187's bound field a boolean field (Yes/No format)? If yes, then
change the If statement to this:

If Me.Combo187.Value = True And _
IsNull([Combo6]) Then

--
Ken Snell
<MS ACCESS MVP>

I tried the code, but it did nothing. I tried this code and it didn't
work
either.
Both fields are bound controls. Combo187 is bound to Paid Salesman and
Combo6 is bound to Employee.
What else can I try ?

Thanks,
Dave

If Me.Combo187.Value = "True" And _
IsNull([Combo6]) Then
MsgBox "You must select a Sales Person."
Cancel = True
Me.Combo6.SetFocus
End If



Sorry...I did misunderstand!

Assuming that you want to "move" the focus to Combo6 in this instance,
I'd
use the form's BeforeUpdate event to trap this error:

Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.Combo187.Value = "True" And _
Len(Me.Combo6.Value & "") = 0 Then
MsgBox "You must select a salesman."
Cancel = True
Me.Combo6.SetFocus
End If
End Sub

--
Ken Snell
<MS ACCESS MVP>


I probably didn't explain, or either I dont understand.

I want the Combo187 which lets you choose either true or
false
if chosen Combo6
 
Back
Top