I'm not sure which forum I should post this in so Mods if you feel that it is in the wrong forum I apologise in advance
on my form I have a Label that I want to contain A customers contact details these fields are stored in a table using the following format
SiteCompanyName
SiteContactTitle
SiteContactFirstName
SiteContactSurname
SiteAddressLine1
SiteAddressLine2
SiteAddressLine3
SiteAddressLine4
SiteAddressCounty
SiteAddressPostCode
SitePhoneNumber
SiteMobileNumber
not all customers have all fields completed (some may only have 1 or 2) I am currently using Dlookup to gain each entry as a variant then checking if the field isNull before adding a label to the form with all the details.
This causes empty lines in the label on the form and I would like be able to ignore the empty fields my code looks like below
are there any suggestions on how I can simplify my code and avoid the unnecessary empty lines
Thanks in Advance
Rudger
on my form I have a Label that I want to contain A customers contact details these fields are stored in a table using the following format
SiteCompanyName
SiteContactTitle
SiteContactFirstName
SiteContactSurname
SiteAddressLine1
SiteAddressLine2
SiteAddressLine3
SiteAddressLine4
SiteAddressCounty
SiteAddressPostCode
SitePhoneNumber
SiteMobileNumber
not all customers have all fields completed (some may only have 1 or 2) I am currently using Dlookup to gain each entry as a variant then checking if the field isNull before adding a label to the form with all the details.
This causes empty lines in the label on the form and I would like be able to ignore the empty fields my code looks like below
Code:
Dim cn As Variant
Dim fn As Variant
Dim a1 As Variant
Dim a2 As Variant
Dim a3 As Variant
Dim a4 As Variant
Dim ac As Variant
Dim ap As Variant
fn = DLookup("[siteformal]", "CustomerDetailsQ", "customerID=" & CustomerID)
cn = DLookup("[SiteCompanyname]", "CustomerDetailsQ", "customerID=" & CustomerID)
a1 = DLookup("[SiteAddressLine1]", "CustomerDetailsQ", "customerID=" & CustomerID)
a2 = DLookup("[SiteAddressLine2]", "CustomerDetailsQ", "customerID=" & CustomerID)
a3 = DLookup("[SiteAddressLine3]", "CustomerDetailsQ", "customerID=" & CustomerID)
a4 = DLookup("[SiteAddressLine4]", "CustomerDetailsQ", "customerID=" & CustomerID)
ac = DLookup("[SiteAddressCounty]", "CustomerDetailsQ", "customerID=" & CustomerID)
ap = DLookup("[SiteAddressPostCode]", "CustomerDetailsQ", "customerID=" & CustomerID)
If IsNull(fn) Then fn = " "
If IsNull(cn) Then cn = " "
If IsNull(a1) Then a1 = " "
If IsNull(a2) Then a2 = " "
If IsNull(a3) Then a3 = " "
If IsNull(a4) Then a4 = " "
If IsNull(ac) Then ac = " "
If IsNull(ap) Then ap = " "
Me.lblCustomerDetails.Caption = fn + vbCrLf + cn + vbCrLf + a1 + vbCrLf + a2 + vbCrLf + a3 + vbCrLf + a4 + vbCrLf + ac + vbCrLf + ap
are there any suggestions on how I can simplify my code and avoid the unnecessary empty lines
Thanks in Advance
Rudger