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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Lookup Field Value Stored 1

Status
Not open for further replies.

joatmofn

Technical User
Jan 12, 2003
72
US
Two questions regarding the value stored for a lookup field.

1) Is the value of a lookup field set to null when nothing is selected from the list?

2) Assume that a record has a list id stored in the lookup field, How can I set the lookup field back to NOTHING as though a list selection was never made? I tried setting it to NULL in the form module's code, but got an error for trying to set it to null. I also tried clearing the list field on the form, but got an error there too.

any help would be appreciated.
Thanks.


 
Whoops!

In my original post for this topic, I made a mistake. I said that I got an error when clearing the list value from the form. This not true.

I need to clear the stored value for the list selection from code. here's why...

On the form there are two combo boxes, call them masterbox, and slavebox. On a new record, the masterbox is displayed, and the slavebox is not visible.

Once a specific selection is made from the masterbox, the slavebox becomes visible. Actually, there is one particular list item that requires the slavebox to become visible. Upto now, making the slavebox visible and not-visible based on the masterbox selection works fine.

The problem is when the slavebox selection needs to be cleared and the stored value in the record set to null.

How can I set the combobox (slavebox) to null with code?

I have an afterupdate event on the masterbox. When the masterbox selection changes to a list item that does not require the slavebox I need to set the field value for the slavebox to null.

I tried setting the slavebox's listindex to -1 and to null, but each produced an error saying that I used the listindex property incorrectly.

Any help on this would be appreciated.

Thanks.
 
In the after update of the masterbox
Code:
   Me.cboSlaveBox = Null
This should work unless the table doesn't allow null values. I assume all your lookups are set up in forms and not in the tables
Duane
MS Access MVP
Find out how to get great answers faq219-2884.
 
Suddenly, what seems to be more important than the problem I posted about is the fact that I have dozens of lookups at the table level.

Thanks for the link to the looupfields.htm.

Regarding the problem, I removed the lookup from the table and was able to set the control to null. Thanks.

Here's a star.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top