Populate other fields from a combo box

krispetrie

New member
Local time
Today, 22:22
Joined
Apr 12, 2001
Messages
8
I found the following code in a response from prao but that topic disappeared. What do I do if one of the fields that is populating the form is blank. This code puts me in a debug loop.
Private Sub cmdbankername_BeforeUpdate(Cancel As Integer)
Me.BankerFullName = Me.cmdbankername.Column(0)
Me.BankerFirstName = Me.cmdbankername.Column(1)
Me.BankerLastName = Me.cmdbankername.Column(2)
Me.OfficerCode = Me.cmdbankername.Column(3)
Me.CenterName = Me.cmdbankername.Column(4)
Me.ClusterName = Me.cmdbankername.Column(5)
Me.DistrictName = Me.cmdbankername.Column(6)
Me.State = Me.cmdbankername.Column(7)
Me.IDOName = Me.cmdbankername.Column(8)
Me.EmployeeIdentifier = Me.cmdbankername.Column(9)
End Sub
 
By "blank", I assume you mean Null. If so, use the intrinsic Nz function to convert a possibly Null value into a zero, an empty string, or any other desired value (Nz is well document in the on-line help).

If you are concerned about blank or empty strings, you can simply test for them using the Trim function, and assign alternate values as desired.

This example will catch and correct any of the above (Null, empty or blank):

Me.State = IIf(Trim(Nz(Me.cmdbankername.Column(7)),"") = "", "[the actual value was Null, empty or blank", Me.cmdbankername.Column(7))
 

Users who are viewing this thread

Back
Top Bottom