validation for combobox

S

steve a

Hi,
I'm trying to get a command button to check that the entry in a combo box is
on the row source (sourced from another table which the form is not bound
to), even partial entries. so only complete entries are added..
I'm not sure how togo abouts this. I've tried:

private sub..(usual stuff). on click

If Me.combo.Value = [tblall2].name Then
Forms![activity form].txtname = Me.combo
DoCmd.Close
Else
'MsgBox "please enter a valid name"
'End If

end sub
where tblall2.name is the row which contains the names to check against.
i've tried the limit to list, but unfortunately this doesnt work..

any help would be appreciated.

many thanks
steve
 
T

Tom van Stiphout

On Wed, 21 Jan 2009 05:56:01 -0800, steve a

I find your question hard to follow, but it appears that you want to
check if the selected value in a combobox occurs in some table.
If that is the case, I would improve the query that fills the
combobox, and exclude items that do not occur there.

And set LimitToList to True.

-Tom.
Microsoft Access MVP
 
S

steve a

Hi tom.
sorry didn't mean to be confusing!
I'll try and explain everything..

I have a form with a "department" option group, which opens another form
where there is a combo box, which people can enter data into (their name) via
an onscreen keyboard. then by clicking a command button this data is
returned to the original form and displayed there.
I would like to limit the input to the combo box to the assigned values
(names) which are in tblall2.name

I currently organise the row source to display the names on the drop down
depending on whcih department they are in, and the drop down populates fine.
I also have the limit to list set to "yes"

i still have a problem that via the onscreen keyboard, any text can be added
and sent to the master form. I would like a popup message to appear if the
data typed into the combo box via the onscreen keyboard does not match the
data in the drop down. when the "ok " button is clicked..

hope that makes things a bit clearer.....

many thanks
Steve

this combo box is unbound, and the value in it is returned to
--
steve adlam


Tom van Stiphout said:
On Wed, 21 Jan 2009 05:56:01 -0800, steve a

I find your question hard to follow, but it appears that you want to
check if the selected value in a combobox occurs in some table.
If that is the case, I would improve the query that fills the
combobox, and exclude items that do not occur there.

And set LimitToList to True.

-Tom.
Microsoft Access MVP


Hi,
I'm trying to get a command button to check that the entry in a combo box is
on the row source (sourced from another table which the form is not bound
to), even partial entries. so only complete entries are added..
I'm not sure how togo abouts this. I've tried:

private sub..(usual stuff). on click

If Me.combo.Value = [tblall2].name Then
Forms![activity form].txtname = Me.combo
DoCmd.Close
Else
'MsgBox "please enter a valid name"
'End If

end sub
where tblall2.name is the row which contains the names to check against.
i've tried the limit to list, but unfortunately this doesnt work..

any help would be appreciated.

many thanks
steve
 
T

Tom van Stiphout

On Wed, 21 Jan 2009 07:44:01 -0800, steve a

You wrote: "i still have a problem that via the onscreen keyboard, any
text can be added and sent to the master form."
But that's not true if the combobox is LimitToList. Then the user MUST
enter text that occurs in the list.

-Tom.
Microsoft Access MVP
 

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