Validation Question

g@v

Registered User.
Local time
Today, 23:14
Joined
Feb 14, 2005
Messages
14
Hi again :)

Another question if I may...If I have a Form with a Field called "Export" which is set as a "Yes/No" Data type, how would I say... If another Field called "PC" has a combo box with DELL, HP, IBM then the "Export" field would require to be set ONLY if DELL or IBM is ticked on the form.

Thanks again for any tips
 
So the Export field is actually calculated and should not be stored in the table. Calculate it like...
Code:
Export = Me.PC = "Dell" OR Me.PC = "HP"
If you store it in the table and someone changes the value of PC...
See? Unnecessary dependency - is like running with scissors.
 
Maybe I'm missing something here... But I don't see the "Export" field as "calculated"... Yes/No... boolean..... Your answering a question, not making a calculation.
If it is a "Dell" or "IBM" then you want to know if it was exported correct? And the Dell,IBM,HP comes from a dropdown right? And would have an ID... eg... 1-Dell, 2-IBM, 3-HP..... so on
My thought would be to create an option group named like..."optExport" with "Yes" and "No" buttons, and the code below names your combo box as "cboPC"
then

If Me.cboPC = 1 Or 2 and IsNull(optExport) Or optExport = "" Then
MsgBox "YES or NO required in Export? field", vbCritical + vbOKOnly + vbDefaultButton1, "Missing Data"
Cancel = True
End If

(air code... you might haveto play with it).....
 
Thanks for replying, what I'm trying to do is on a Form I have a combo box called Makes with the items as DELL, HP, IBM so on, and I have a Licence Field as tick box data type.

I would like it so that the user wouldn't be able to exit the form if the Licence field was not ticked and the makes item dell was choosen so then a message would pop up saying "DELL Needs licence please tick box"

I've tried something like this...

Private Sub Form_Close()
If ([Licence]) Then
Select Case Me.Makes
Case "DELL"
Me.Licence = "Need to tick box."
Case Else
Me.Licence = "Continue without ticking"
End Select
End If
End Sub

But I probably not understanding something here :(

Many thanks again to this great site for any tips/hints
 
Do you need the user to decide something like, if A then sometimes B? Or is there a fact about your data that you need to assert like, if A then always B?
- In the first case you need the user to determine the solution, and since there might be a variety of anwers, you need a field in a table.
- In the second case there is a linear relationship such that B varies directly with A. In this case do not store B in a table. Calculate it from A. More specifically...
Code:
'ID references removed for clarity
If Me.PC = "Dell" Or Me.PC = "HP" Then  
  Me.License = True
Else
  Me.License = False
End If
This is more simply expressed as...
Code:
Me.License = (Me.PC = "Dell" OR Me.PC = "HP")
Does this help you or am I missing your point?
 
Yes, it is a little confusing! If "Dell" requires a license..why the message box?
If Me.Fieldwhatever = "Dell" Then
me.checkbox = True

What you have above is a combination of a "If...Then" statement... A "Select Case" statement and a message box.
Do a search on those three, you'll probably find your answer. As you see lagbolt has shown you an "If...Then" statement is pretty straight forward. You might start by looking at the bottom of this page for "Similar post"
 

Users who are viewing this thread

Back
Top Bottom