473,473 Members | 2,025 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

ComboBox (Null value variable error)

Private Sub cboBody_KeyDown(KeyCode As Integer, SHIFT As Integer)
'Delete combobox entry if Del or Backspace key is hit.
If (KeyCode = 46) Or (KeyCode = 8) Then Me.cboBody = ""
End Sub

I have used identical code in the KeyDown event of my other comboboxes
to clear the box when
the delete or backspace key is pressed. It works for many identical
comboboxes just fine except
for the cboBody combo. I have looked this over and cannot find any
differences in the combobox's that are working ans the one that is
not I get the following error message?

Error: "You tried to assign the Null value to a variable that is not a
Variant data type"

Is the combobox a variable? Any ideas?

Jul 25 '08 #1
4 4884
JvC
Your combo box is bound to a field in the database. The field won't
accept null values. You need to go into the table design, and allow the
field to allow nulls.

John

reg (co*****@gmail.com) formulated the question :
Private Sub cboBody_KeyDown(KeyCode As Integer, SHIFT As Integer)
'Delete combobox entry if Del or Backspace key is hit.
If (KeyCode = 46) Or (KeyCode = 8) Then Me.cboBody = ""
End Sub

I have used identical code in the KeyDown event of my other comboboxes
to clear the box when
the delete or backspace key is pressed. It works for many identical
comboboxes just fine except
for the cboBody combo. I have looked this over and cannot find any
differences in the combobox's that are working ans the one that is
not I get the following error message?

Error: "You tried to assign the Null value to a variable that is not a
Variant data type"

Is the combobox a variable? Any ideas?

Jul 25 '08 #2
Thanks JvC

But my other combo boxes are working. And, yes you are correct they
are bound to a Tables field, but I do not
see, in table design, where I would allow a field to accept null
values? The field by the way is LongInteger as is the case
in the other comboboxes that are working.

Thanks Greg
On Jul 25, 3:12*pm, JvC <johnv...@earthlink.netwrote:
Your combo box is bound to a field in the database. The field won't
accept null values. You need to go into the table design, and allow the
field to allow nulls.

John

reg (code...@gmail.com) formulated the question :
Private Sub cboBody_KeyDown(KeyCode As Integer, SHIFT As Integer)
* *'Delete combobox entry if Del or Backspace key is hit.
* * If (KeyCode = 46) Or (KeyCode = 8) Then Me.cboBody = ""
End Sub
I have used identical code in the KeyDown event of my other comboboxes
to clear the box when
the delete or backspace key is pressed. *It works for many identical
comboboxes just fine except
for the cboBody combo. *I have looked this over and cannot find any
differences in the combobox's that are working ans the one that is
not * * * * I get the following error message?
Error: "You tried to assign the Null value to a variable that is not a
Variant data type"
Is the combobox a variable? *Any ideas?- Hide quoted text -

- Show quoted text -
Jul 25 '08 #3
JvC
Greg,

Strange! You can't ever assign a null to a long integer. Try setting
cboBody to 0, and see if that works.

John

Greg (co*****@gmail.com) used his keyboard to write :
Thanks JvC

But my other combo boxes are working. And, yes you are correct they
are bound to a Tables field, but I do not
see, in table design, where I would allow a field to accept null
values? The field by the way is LongInteger as is the case
in the other comboboxes that are working.

Thanks Greg
On Jul 25, 3:12*pm, JvC <johnv...@earthlink.netwrote:
>Your combo box is bound to a field in the database. The field won't
accept null values. You need to go into the table design, and allow the
field to allow nulls.

John

reg (code...@gmail.com) formulated the question :
>>Private Sub cboBody_KeyDown(KeyCode As Integer, SHIFT As Integer)
* *'Delete combobox entry if Del or Backspace key is hit.
* * If (KeyCode = 46) Or (KeyCode = 8) Then Me.cboBody = ""
End Sub
>>I have used identical code in the KeyDown event of my other comboboxes
to clear the box when
the delete or backspace key is pressed. *It works for many identical
comboboxes just fine except
for the cboBody combo. *I have looked this over and cannot find any
differences in the combobox's that are working ans the one that is
not * * * * I get the following error message?
Error: "You tried to assign the Null value to a variable that is not a
Variant data type"
>>Is the combobox a variable? *Any ideas?- Hide quoted text -

- Show quoted text -

Jul 25 '08 #4
Private Sub cboBody_KeyDown(KeyCode As Integer, SHIFT As Integer)
'Delete combobox entry if Del or Backspace key is hit.
If (KeyCode = 46) Or (KeyCode = 8) Then Me.cboBody = "" '<--- I
changed this to 0, and it worked
End Sub

I assigned the Me.cboBody = 0 instead of = "" and it worked.
What's confusing is why the other comboboxes accepted "" and they are
also storing numbers.


On Jul 25, 3:32*pm, "Greg (code...@gmail.com)" <code...@gmail.com>
wrote:
Thanks JvC

But my other combo boxes are working. *And, yes you are correct they
are bound to a Tables field, but I do not
see, in table design, where I would allow a field to accept null
values? The field by the way is LongInteger as is the case
in the other comboboxes that are working.

Thanks Greg

On Jul 25, 3:12*pm, JvC <johnv...@earthlink.netwrote:
Your combo box is bound to a field in the database. The field won't
accept null values. You need to go into the table design, and allow the
field to allow nulls.
John
reg (code...@gmail.com) formulated the question :
Private Sub cboBody_KeyDown(KeyCode As Integer, SHIFT As Integer)
* *'Delete combobox entry if Del or Backspace key is hit.
* * If (KeyCode = 46) Or (KeyCode = 8) Then Me.cboBody = ""
End Sub
I have used identical code in the KeyDown event of my other comboboxes
to clear the box when
the delete or backspace key is pressed. *It works for many identical
comboboxes just fine except
for the cboBody combo. *I have looked this over and cannot find any
differences in the combobox's that are working ans the one that is
not * * * * I get the following error message?
Error: "You tried to assign the Null value to a variable that is not a
Variant data type"
Is the combobox a variable? *Any ideas?- Hide quoted text -
- Show quoted text -- Hide quoted text -

- Show quoted text -
Jul 25 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: ColinWard | last post by:
Hi again. I am trying to figure out how to make sure that a value has been selected from a combobox on a form. I have tried using isnull(comboboxname.text) and isempty(comboboxname.text)and...
1
by: Tony Williams | last post by:
I have a dropdown box called cmbCompany2 which is based on a table tblCompany on a form frmMain which is based on a table tblMain. The data selected in the combobox is stored in the field...
8
by: Zlatko Matić | last post by:
There is a form (single form) and a combobox. I want that current record of the form is adjusted according to selected value in the combobox. Cuurrent record should be the same as the value in the...
3
by: PeterZ | last post by:
G'day, After doing much searching and pinching bits of ideas from here there and everywhere I came up with a fairly 'clean' solution of including a comboBox into a dataGrid column. You can...
2
by: pei_world | last post by:
I want to implement a key hit with enter to dropdown a combobox that is in the datagrid. in this case I need to override its original behaviours. I found some codes from the web. Does anyone know...
0
by: Doug | last post by:
This is a repost of an item that I still cannot resolve. I have 3 combo boxes. The first leads to the second to the third. When I have selected a value in the second box, the third box shows...
1
by: freekedoutfish | last post by:
Hi. New member here Im sat at work, pounding my head off the desk because this tiny bit of simple code refuses to work. The sub is intended to pull data from the "companyname" column in the...
3
by: Simon Tamman | last post by:
I've come across an interesting bug. I have workarounds but i'd like to know the root of the problem. I've stripped it down into a short file and hope someone might have an idea about what's going...
3
by: Gerrit | last post by:
Hi, I try to learn programming in c# with databinding controls. Now I have a problem with a ComboBox with the advanced properties for databinding, I want to set the DataSourceUpdateMode to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.