Re: clear integer values in text boxes

alicejwz

Registered User.
Local time
Today, 15:50
Joined
Jul 9, 2003
Messages
91
Re: clear integer values in text boxes

Hi all,

I have a problem clearing or displaying empty values in text boxes.
These fields are binding to a table and are storing integer data type. I want to clear the values in these text boxes when user clicks on a button but the fields that stores the number gives me this error message:
Run time error 2757
There was a problem accessing a property or method of the OLE object.

here is my code:
Private Sub msp_barcode_Click()
Me!msp_barcode.Value = ""
Me!material_lotnum.Value = ""
Me!insert_lotnum.Value = ""
Me!mfg_dt.Value = ""

doesn't work
Me!bag_num.Value = ""
Me!bag_quantity.Value = ""

works
Me!bag_num.Value = 0
Me!bag_quantity.Value = 0

It makes sense not be able to store empty string in integer field but I can't figure how?

I appreciate your input.
 
Code:
Me.MyControl = Null

Do you have the fields set to AllowNullLength values?
 
Re: Clear integer values in text boxes

Hi McAbney,

Thanks for your response.
It still gives me the same error message.

I tried the followings and they don't work
Me!bag_num.Text = “”
Me!bag_num.value = “”
Me!bag_num.Text = Null

The controls are bind to a table in the form. And the fields are storing integer and the fields can't store null values.
I'm using AC2K and SQL Server 2K.
I would appreciate Any suggestions .
 
Try me.Control.value = Empty
Sometimes you just need to set them to something other than Null since null is considered a value.
 
Did you check the properties of the relevant fields in the table with respect to the Allow Null Length values?
 
Hi,

Thanks for the replies.

I think that is the issue.
The bag_num and bag_quantity fields are set to not allow null values in the table. Since I can clear the other fields with syntax below.

work
Me!msp_barcode.Value = ""
Me!material_lotnum.Value = ""
Me!insert_lotnum.Value = ""
Me!mfg_dt.Value = ""

doesn't work
Me!bag_num.Value = ""
Me!bag_quantity.Value = ""

what I'm trying to do is display blank in the bag_num and bag_quantity fields when I save the record these fields will not be null or empty.

This is how it works.
When the other fields are populated and user clicks on msp_barcode field on the form it needs clear all fields except for an ID field. After user types in msp_barcode the fields will either populate with new data or user will need to enter the other fields. No matter what the the bag_num and bag_quantity field will have a value when the record is saved.
All I'm trying to do is clear the fields when user clicks on msp_barcode field.
I don't want to change the properties to allow null because there has a value in these fields when the record is being saved.

I hope I explain my issue and you can help.
Thank you.
 
Re: Clear integer values in text boxes

Hi,

Thanks for the replies.

I think that is the issue.
The bag_num and bag_quantity fields are set to not allow null values in the table. Since I can clear the other fields with syntax below.

work
Me!msp_barcode.Value = ""
Me!material_lotnum.Value = ""
Me!insert_lotnum.Value = ""
Me!mfg_dt.Value = ""

doesn't work
Me!bag_num.Value = ""
Me!bag_quantity.Value = ""

what I'm trying to do is display blank in the bag_num and bag_quantity fields when I save the record these fields will not be null or empty.

This is how it works.
When the other fields are populated and user clicks on msp_barcode field on the form it needs clear all fields except for an ID field. After user types in msp_barcode the fields will either populate with new data or user will need to enter the other fields. No matter what the the bag_num and bag_quantity field will have a value when the record is saved.
All I'm trying to do is clear the fields when user clicks on msp_barcode field.
I don't want to change the properties to allow null because there has a value in these fields when the record is being saved.

I hope I explain my issue and you can help.
Thank you.
 

Users who are viewing this thread

Back
Top Bottom