Cant work with Option Group values

  • Thread starter Thread starter Lee
  • Start date Start date
L

Lee

Hi there,
As usual I'm getting stuck on syntax but I think I've tried
all permutations so am at a loss how to proceed.
I have an option group on a form. The bound frame is
called FeesFrame and the frame is bound to a table field
called FeeTypeValue. The user can chose one out of 6
options.
I'm trying to write some simple validation where, if the
user selects either option 1 or option 2 AND the country is
not in the UK then a message appears as a reminder (it's
not a critical error). Some hope!!
Can you tell me where I'm going wrong here?
This is under the 'after update' event of the Frame:

If [FeesFrame] = 3 Or 4 And [ToCountry] = "UK" Or "Wales"
blah, blah Then
MsgBox "...you have selected a UK fee for an Overseas
arrangement?", vbQuestion, "Do you realise..."
End If

I've tried: If [FeesFrame]=3 Or [FeesFrame]=4.....
If [FeeTypeValue]=3 Or [FeeTypeValue]=4
If [FeesFrame].Value = 3 .............
 
I think I would use the following but this does depend on the correct case
being used when entering the country:

Select Case Me.Frame1
Case 1
If Nz(Me.Text12.Value, "") <> "UK" And Nz(Me.Text12.Value, "") <> "WALES"
Then
MsgBox "error"
End If
Case 2
If Nz(Me.Text12.Value, "") <> "UK" And Nz(Me.Text12.Value, "") <> "WALES"
Then
MsgBox "error"
Case 3
Msgbox "OK"
End Select
 
Lee,
To help you understand the If..Then syntax for just a few choices, this
should help:

You must repeat the associated "[Field] = " for each criteria.

If ([FeesFrame] = 3 Or [FeesFrame] = 4) And ([ToCountry] = "UK" Or
[ToCountry] = "Wales" ) Then
MsgBox "...you have selected a UK fee for an Overseas arrangement?",
vbQuestion, "Do you realise..."
End If

To add more permutations you could also use:

If ... Then
Elseif ... Then
Elseif ... Then
Else
End If

In which case a Select Case would be easier to read and maintain.
 
Thanks Fred and Newbie,
I've gone with the Select statement which, as you suggest,
is preferable.

This is what I wrote:
Select Case Me![ToCountry]
Case "UK", "Wales", "Scotland", "N Ireland", "N.
Ireland", "N. Ireland", "Northern Ireland"
If [FeesFrame] = 3 Then
MsgBox "...you have selected an Overseas fee
(blah, blah)....
ElseIf: [FeesFrame] = 4 Then
(blah, blah)....

I shall get the hang of this one day!!!

Regards,

Lee
-----Original Message-----
Lee,
To help you understand the If..Then syntax for just a few choices, this
should help:

You must repeat the associated "[Field] = " for each criteria.

If ([FeesFrame] = 3 Or [FeesFrame] = 4) And ([ToCountry] = "UK" Or
[ToCountry] = "Wales" ) Then
MsgBox "...you have selected a UK fee for an Overseas arrangement?",
vbQuestion, "Do you realise..."
End If

To add more permutations you could also use:

If ... Then
Elseif ... Then
Elseif ... Then
Else
End If

In which case a Select Case would be easier to read and maintain.
--
Fred

Please reply only to this newsgroup.
I do not reply to personal e-mail.


Lee said:
Hi there,
As usual I'm getting stuck on syntax but I think I've tried
all permutations so am at a loss how to proceed.
I have an option group on a form. The bound frame is
called FeesFrame and the frame is bound to a table field
called FeeTypeValue. The user can chose one out of 6
options.
I'm trying to write some simple validation where, if the
user selects either option 1 or option 2 AND the country is
not in the UK then a message appears as a reminder (it's
not a critical error). Some hope!!
Can you tell me where I'm going wrong here?
This is under the 'after update' event of the Frame:

If [FeesFrame] = 3 Or 4 And [ToCountry] = "UK" Or "Wales"
blah, blah Then
MsgBox "...you have selected a UK fee for an Overseas
arrangement?", vbQuestion, "Do you realise..."
End If

I've tried: If [FeesFrame]=3 Or [FeesFrame]=4.....
If [FeeTypeValue]=3 Or [FeeTypeValue]=4
If [FeesFrame].Value = 3 .............


.
 
Can I suggest it would be better if the focus of the Select Statement was
the FeesFrame and perhaps the country field was a combobox based on a table
By having a combobox the user can only select the correct format for the
country thereby removing the need to cater for all different ways of typing
the country - as in your example "N Ireland", "N.Ireland","Northern Ireland"

HTH

Al
Lee said:
Thanks Fred and Newbie,
I've gone with the Select statement which, as you suggest,
is preferable.

This is what I wrote:
Select Case Me![ToCountry]
Case "UK", "Wales", "Scotland", "N Ireland", "N.
Ireland", "N. Ireland", "Northern Ireland"
If [FeesFrame] = 3 Then
MsgBox "...you have selected an Overseas fee
(blah, blah)....
ElseIf: [FeesFrame] = 4 Then
(blah, blah)....

I shall get the hang of this one day!!!

Regards,

Lee
-----Original Message-----
Lee,
To help you understand the If..Then syntax for just a few choices, this
should help:

You must repeat the associated "[Field] = " for each criteria.

If ([FeesFrame] = 3 Or [FeesFrame] = 4) And ([ToCountry] = "UK" Or
[ToCountry] = "Wales" ) Then
MsgBox "...you have selected a UK fee for an Overseas arrangement?",
vbQuestion, "Do you realise..."
End If

To add more permutations you could also use:

If ... Then
Elseif ... Then
Elseif ... Then
Else
End If

In which case a Select Case would be easier to read and maintain.
--
Fred

Please reply only to this newsgroup.
I do not reply to personal e-mail.


Lee said:
Hi there,
As usual I'm getting stuck on syntax but I think I've tried
all permutations so am at a loss how to proceed.
I have an option group on a form. The bound frame is
called FeesFrame and the frame is bound to a table field
called FeeTypeValue. The user can chose one out of 6
options.
I'm trying to write some simple validation where, if the
user selects either option 1 or option 2 AND the country is
not in the UK then a message appears as a reminder (it's
not a critical error). Some hope!!
Can you tell me where I'm going wrong here?
This is under the 'after update' event of the Frame:

If [FeesFrame] = 3 Or 4 And [ToCountry] = "UK" Or "Wales"
blah, blah Then
MsgBox "...you have selected a UK fee for an Overseas
arrangement?", vbQuestion, "Do you realise..."
End If

I've tried: If [FeesFrame]=3 Or [FeesFrame]=4.....
If [FeeTypeValue]=3 Or [FeeTypeValue]=4
If [FeesFrame].Value = 3 .............


.
 
Back
Top