Pit may be null- getting can't have zero length string error

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Below is the code I have attached to the after update event of a combo box-
basically filling in fields when a quoteid is selected- however the [pit]
field may be null and that's okay but it is giving me an error see subject
above and taking me into the VB code to debug how can I say its okay to be
empty with the code below???


If [cbquoteid] <> 0 Then [cost] = Me.cbquoteid.Column(3): [ClientId] =
Me.cbquoteid.Column(2): [Pit] = Me.cbquoteid.Column(5): [Divisor] =
Me.cbquoteid.Column(10): [GrossWeight] = Me.cbquoteid.Column(11): [Markup] =
Me.cbquoteid.Column(6): [OverallMarkup] = Me.cbquoteid.Column(4):
[CartageRate] = Me.cbquoteid.Column(13): [FuelperRate] =
Me.cbquoteid.Column(14): [Comments] = Me.cbquoteid.Column(15): [Taxex] =
Me.cbquoteid.Column(12): [zone] = Me.cbquoteid.Column(17)

thanks,
Barb
 
I would suggest you post your statements as separate lines instead of
separating them with semicolons. If you want people to help you, you need to
help them by making your post as easy to read as possible. See
http://www.mvps.org/access/netiquette.htm for other good suggestions on
effective use of newsgroups.

Larry Linson
Microsoft Access MVP
 
thanks for the input. Just realized any one of the fields could possibly be
null - Is there any code I can put in front of the entire existing string to
handle the possibility of Null for all for all of the columns.


Thanks,
Barb

mscertified said:
You probably have the column defined as 'allow zero length = NO".

Try the following code which will only do the operation if it is not null:

If NZ(Me.cbquoteid.Column(5),0) <> 0 Then:
[Pit] = Me.cbquoteid.Column(5)
end if

-Dorian

babs said:
Below is the code I have attached to the after update event of a combo box-
basically filling in fields when a quoteid is selected- however the [pit]
field may be null and that's okay but it is giving me an error see subject
above and taking me into the VB code to debug how can I say its okay to be
empty with the code below???


If [cbquoteid] <> 0 Then [cost] = Me.cbquoteid.Column(3): [ClientId] =
Me.cbquoteid.Column(2): [Pit] = Me.cbquoteid.Column(5): [Divisor] =
Me.cbquoteid.Column(10): [GrossWeight] = Me.cbquoteid.Column(11): [Markup] =
Me.cbquoteid.Column(6): [OverallMarkup] = Me.cbquoteid.Column(4):
[CartageRate] = Me.cbquoteid.Column(13): [FuelperRate] =
Me.cbquoteid.Column(14): [Comments] = Me.cbquoteid.Column(15): [Taxex] =
Me.cbquoteid.Column(12): [zone] = Me.cbquoteid.Column(17)

thanks,
Barb
 
Back
Top