HOW TO... set a combo box to NULL which is part of a PRIMARY KEY

K

Kevin McCartney

HI TWIMC

I have two combo boxes that hold employee id and role id, both of which are
a part of the PRIMARY KEY for their table. The problem is that when a user
selects an employee name from the combo box and decides to delete the
selected item, Access pops up the message "You tried to assign a Null value
to a variable that is not a variant data type", this happens before any
events like BeforeInsert, Afterupdate, Exit etc. So my question is, how can I
allow the user to delete the selected item and not show the Access message.


TIA
KM
 
A

Allen Browne

Train the user to *undo* the combo.

You can undo by pressing the Esc key, clicking the Undo button on the
toolbar, or choosing Undo on the Edit menu.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

message
news:[email protected]...
 
K

Kevin McCartney

Train the user to *undo* the combo. No hope in that working.....

Anyone else have any ideas?
Please

TIA
KM
 
O

Ofer

On the before update event you can enter the code

If isnull(Me.[employee id]) Or Me.[employee id] = "" Or Isnull(Me.[role id])
Or Me.[role id] = "" Then
DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
' To undo the changes that been made
End If
 

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

Similar Threads


Top