View Full Version : Populating fields are empty and I get an error


Randomblink
10-05-2001, 01:34 PM
I have a combo box...

There are 5 columns in this box...

Whenever I select a record from the combo box I have VB code that populates fields on my form based on the columns in that combo box...

Well, I just ran into (for the first time) records where some of those fields in the combo box are empty...

When the VB code tries to populate the fields it pops up with a message that says:

Field '<table_name>.<field_name>' cannot be a zero-length string.

The commands I am using are like this:
Private Sub Project_Selector_Combo_AfterUpdate()
INVOICE_NUM.SetFocus
Project_Selector_Combo.Visible = False
txt_Engineer_Name = (Me.Project_Selector_Combo.Column(2))
txt_Engineer_Name.Visible = True
txt_project_number = (Me.Project_Selector_Combo.Column(1))
txt_project_number.Visible = True
txt_Accounting_Code = (Me.Project_Selector_Combo.Column(4))
txt_Project_Title = (Me.Project_Selector_Combo.Column(3))
btn_change_account_code.Visible = True
btn_change_project_number.Visible = True
End Sub

This is the code I have...
Can someone help...?

Travis
10-05-2001, 03:43 PM
One way to fix this is to change the Allow Zero Length Property of the Fields in the Table.

Otherwise try this

txt_Engineer_Name = iif(NZ(Me.Project_Selector_Combo.Column(2),"")=""," ",Me.Project_Selector_Combo.Column(2))

This places a space in though and not exactly the best option. I would change the tables fields properties.