Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

How do I clear the value of a combobox?

Avatar of yoducati
yoducati asked on
Microsoft Access
19 Comments1 Solution274 ViewsLast Modified:
I have a data entry form with a tabbed form control for tracking mail our office processes.  The first tab is for sending new mail(data entry), second tab is for viewing past mail, third is for printing labels etc.  Here's the problem.  On my tab for sending mail I have two comboboxes, cboOffice and cboRecipient.  From these two comboboxes the user selects which of our offices is to receive the mail, and then the individual.  These two combo boxes are part of an option group that from which the user can choose OptionA (select one of our offices) or optionB (manually type an address).  I have code in VBA that checks to see if the user has selected optionA and if so it checks to make sure the user has selected both an office and recipient before it will let them continue.  The problem is that even though the combo boxes dont have anything in them the database still thinks something is selected and therefore skips over the code checking to see if they are blank.  I ve tried adding me.cboOffice=Null and me.cboRecipient=null in several different events and have eliminated the problem of the database thinking the combo boxes have something in them.  The problem now is when I try to close the form I get the error "index or primary key cannot be null".  neither of the combo boxes are the primary key and I havent entered anything in the form at this point.  I just open and close it and get the error.  If I remove the me.cboOffice=Null and Me.cboRecipient = null the "index or primary key cannot be null" message goes away but then the database goes back to thinking the combo boxes have a value selected when they do not and therefore skips over the code I have checking to see if they are blank.
Avatar of yoducati

Our community of experts have been thoroughly vetted for their expertise and industry experience.

This problem has been solved!
Unlock 1 Answer and 19 Comments.
See Answers