I am populating record information into text boxes of an MS Access Form from another Access database table using an ADODB connection.
I link the ControlSource of each text box to the value of the record's appropriate field from the retrieved recordset rsContacts, the code breaks when the record field (in this case the Address2 text field) of the original recordset rsContacts is Null.
How do I allow for null values?
'populate the controls of the form with the values of the current record
'in the local disconnected recordset.
If Not rsContacts.BOF And Not rsContacts.EOF Then
Me.txtLastName.ControlSource = rsContacts!txtLastName
Me.txtFirstName.ControlSource = rsContacts!txtFirstName
Me.txtMiddleName.ControlSource = rsContacts!txtMiddleName
Me.txtTitle.ControlSource = rsContacts!txtTitle
Me.txtAddress1.ControlSource = rsContacts!txtAddress1
Me.txtAddress2.ControlSource = rsContacts!txtAddress2
Me.txtCity.ControlSource = rsContacts!txtCity
Me.txtState.ControlSource = rsContacts!txtState
Me.txtZip.ControlSource = rsContacts!txtZip
Me.txtWorkPhone.ControlSource = rsContacts!txtWorkPhone
Me.txtHomePhone.ControlSource = rsContacts!txtHomePhone
Me.txtCellPhone.ControlSource = rsContacts!txtCellPhone
ElseIf rsContacts.BOF Then
'past beginning of recordset so move to next record
ElseIf rsContacts.EOF Then
'past end of recordsete so move to previous record