Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ComboBox - Validating Selection

Status
Not open for further replies.

vfisher

Programmer
Apr 15, 2002
40
US
I have a combo box getting values from a table. Once the value is selected, either the ADD record button or Edit record button must be selected. Then some validation needs to occur: For an add, only some of the values available in the combo box are valid.

The probem is that the record is not yet saved and I can't seem to use the right field in the If statement. I've tried the Form.Controlsource and the table column, but get a type mismatch or "cant find the field" error.

I'm sure I'm just doing something stupid, but I just can figure this out.

Thanks.
 
I'm not sure I understand. When you say
For an add, only some of the values available in the combo box are valid., do you mean that the ADD button can only be clicked if certain values in the combo are selected? In other words, if I select "FOO" in the combo, it should not be possible to use the ADD button?

If you clarify your post, I'm sure someone can help out.

There are two ways to argue with a woman - neither one works.
Another free Access forum:
More Access stuff at
 
Yes. I have a combo box for selecting a transaction type. Some types are valid for adding a record, the others valid for editing the current record. So, when the "Add" button is clicked I want to make sure the transaction is A,B or C and when the "Edit" button is clicked the transaction must be E, F or G.

I can't use the table field since it hasn't actually been updated yet, so I'm not sure how to get the value that was actually selected in the combo box.

Hope that makes more sense.
 
When you process the ADD button click, make sure the combo has returned an appropriate choice:

Sub btnADD_Click()
if me!Combo > "C" then
msgbox "Sorry, you can not use that Transaction type for an ADD..try again, and select E, F or G", vbOKOnly
....
End Sub

and the same basic idea for the EDIT guy.






There are two ways to argue with a woman - neither one works.
Another free Access forum:
More Access stuff at
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top