Validation rule as a query

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How I can put a validation rule on a textbox or
a combobox based on a query. The input must be similar as the output of a
query.

Something like: [cboName]=(Select name FROM Customers ORDER BY name)

Anyone?
 
Jochem

I may be using a different definition of "validation rule".

Are you saying you want the source of your combo box to be a query? If so,
you can do this in form design mode for the combo box, as part of using the
wizard for creating a combo box, or in VBA by setting the control's
RecordSource to the query.

Or have I misunderstood?

--
Regards

Jeff Boyce
Microsoft Office/Access MVP


Microsoft IT Academy Program Mentor
http://microsoftitacademy.com/

Microsoft Registered Partner
https://partner.microsoft.com/
 
Hi Jeff,

Thanks for your reply. What I want is to make sure that when I submit a form
to my database, that the fields are all filled in, and right.

I first thought of the Validation Rule: Is Not Null, but this didn't work
and wasn't enoguh. I want the source of the comboboxes (the query in this
preview) to be the validation rule.

I hope you'll understand what I mean. Don't hesitate to ask again!
Thanks in advance for you cooperation!

Jochem

Jeff Boyce said:
Jochem

I may be using a different definition of "validation rule".

Are you saying you want the source of your combo box to be a query? If so,
you can do this in form design mode for the combo box, as part of using the
wizard for creating a combo box, or in VBA by setting the control's
RecordSource to the query.

Or have I misunderstood?

--
Regards

Jeff Boyce
Microsoft Office/Access MVP


Microsoft IT Academy Program Mentor
http://microsoftitacademy.com/

Microsoft Registered Partner
https://partner.microsoft.com/


Jochem Davids said:
How I can put a validation rule on a textbox or
a combobox based on a query. The input must be similar as the output of a
query.

Something like: [cboName]=(Select name FROM Customers ORDER BY name)

Anyone?
 
Jochem

In Access, combo boxes have a "source" that is a list -- perhaps a value
list or perhaps a list of items returns by a query or table. The "source"
of a combo box isn't a "validation rule".

If you want your form to test for absence of required fields, you can add
code to the BeforeUpdate event of the form that tests, and cancel the
Update/Save if the values are absent. You can also use this to confirm that
the values are appropriate.

If you limit the choices in a combo box to the items lists (LimitToList
property set to Yes), the user won't be able to pick or enter an invalid
value.

--
Regards

Jeff Boyce
Microsoft Office/Access MVP


Microsoft IT Academy Program Mentor
http://microsoftitacademy.com/

Microsoft Registered Partner
https://partner.microsoft.com/


Jochem Davids said:
Hi Jeff,

Thanks for your reply. What I want is to make sure that when I submit a form
to my database, that the fields are all filled in, and right.

I first thought of the Validation Rule: Is Not Null, but this didn't work
and wasn't enoguh. I want the source of the comboboxes (the query in this
preview) to be the validation rule.

I hope you'll understand what I mean. Don't hesitate to ask again!
Thanks in advance for you cooperation!

Jochem

Jeff Boyce said:
Jochem

I may be using a different definition of "validation rule".

Are you saying you want the source of your combo box to be a query? If so,
you can do this in form design mode for the combo box, as part of using the
wizard for creating a combo box, or in VBA by setting the control's
RecordSource to the query.

Or have I misunderstood?

--
Regards

Jeff Boyce
Microsoft Office/Access MVP


Microsoft IT Academy Program Mentor
http://microsoftitacademy.com/

Microsoft Registered Partner
https://partner.microsoft.com/


How I can put a validation rule on a textbox or
a combobox based on a query. The input must be similar as the output of a
query.

Something like: [cboName]=(Select name FROM Customers ORDER BY name)

Anyone?
 
Back
Top