Following is code in a form that is used to produce a new record in the event that one person of two in a household dies, or they separate.
What the code does is take all of the information regarding name, address etc. and create a new record.
Now, say you query the table and, using an IIf function, want to put together an AptNbr (if it exists) and a HouseNbr and Street,
Thus, you should end up with
922 - 14 Olive ST (if there is an AptNbr)
or
14 Olive ST (if there is no AptNbr)
For whatever reason the result is that a hyphen is thrown in, so you get - 14 Olive ST
This only happens when a new record was created using the process below. The baffling thing is that no extra characters show in the table, and when you query the HouseNbr it appears as it should. It's only when you attempt to use the IIF that you run into this problem.
Here's the code.
Do you spot anything in there that should create the issue I am experiencing?
The AptNbr field in the table is set to Text, because the AptNbr could be something such as 5A rather than a number.
Also the "Allow zero length" property is set to Yes. I have tried changing it to No, but it made no difference.
What the code does is take all of the information regarding name, address etc. and create a new record.
Now, say you query the table and, using an IIf function, want to put together an AptNbr (if it exists) and a HouseNbr and Street,
Thus, you should end up with
922 - 14 Olive ST (if there is an AptNbr)
or
14 Olive ST (if there is no AptNbr)
For whatever reason the result is that a hyphen is thrown in, so you get - 14 Olive ST
This only happens when a new record was created using the process below. The baffling thing is that no extra characters show in the table, and when you query the HouseNbr it appears as it should. It's only when you attempt to use the IIF that you run into this problem.
Here's the code.
Code:
NewRecordProcess2:
Call MsgBox(Me.FirstName2 & " will be removed from here and a new record created." _
& vbCrLf & "" _
& vbCrLf & "Envelope #s assigned exclusively to " & FirstName2 & " will be moved to the new record" _
& vbCrLf & " and an End Date of Yesterday's date applied." _
& vbCrLf & "" _
& vbCrLf & "You will then be placed in the Remarks section of the new record" _
& vbCrLf & " in case you wish to change or add to the remarks entered." _
, vbExclamation, "Remove process")
DoCmd.SetWarnings False
strTemp = Me.FirstName2
strTemp2 = IIf(IsNull(Me.LastName2), Me.LastName, Me.LastName2)
strTemp3 = Nz(Me.HouseNbr, "?")
strTemp19 = Nz(Me.AptNbr, "")
strTemp4 = Nz(Me.Street, "?")
strTemp5 = Nz(Me.City, "?")
strTemp6 = Nz(Me.Province, "?")
strTemp7 = Nz(Me.Code, "?")
strTemp8 = Nz(Me.HomePhone, "?")
strTemp9 = Nz(Me.BusPhone, "?")
strTemp10 = Nz(Me.Person2Status, "A")
strTemp11 = IIf(IsNull(Me.Person2DateOfBirth), "", Me.Person2DateOfBirth)
strTemp12 = IIf(IsNull(Me.Person2Baptism), "", Me.Person2Baptism)
strTemp13 = IIf(IsNull(Me.Person2Confirmation), "", Me.Person2Confirmation)
strTemp14 = Me.RemovedHow
strTemp15 = Me.RemovedDate
strTemp16 = Me.FirstName
strTemp17 = Me.LastName
strTemp18 = Nz(Me.Address2, "?")
strTemp20 = Nz(Me.RetHomeID)
' Keep track of location in database and Old Record ID
varBookmark = Me.Bookmark
lngOldUniqueID = Me.UniqueID
' Create new record
DoCmd.GoToRecord , , acNewRec
Me.LastName = strTemp2
Me.FirstName = strTemp
Me.AptNbr = strTemp19
Me.HouseNbr = strTemp3
Me.Street = strTemp4
Me.Address2 = strTemp18
Me.City = strTemp5
Me.Province = strTemp6
Me.Code = strTemp7
Me.HomePhone = strTemp8
Me.BusPhone = strTemp9
Me.Person1Status = strTemp10
Me.Person1DateOfBirth = strTemp11
Me.Person1Baptism = strTemp12
Me.Person1Confirmation = strTemp13
Me.chkPerson1Removed = True
Me.RemovedHow = strTemp14
Me.RemovedDate = strTemp15
Me.RetHomeID = strTemp20
Me.Remarks = "Removed from record for " & strTemp16 & " " & strTemp17 & " on " & Format(Date, "mmmm dd, yyyy")
Do you spot anything in there that should create the issue I am experiencing?
The AptNbr field in the table is set to Text, because the AptNbr could be something such as 5A rather than a number.
Also the "Allow zero length" property is set to Yes. I have tried changing it to No, but it made no difference.