R
Robin S.
I have a subform which lists specifications for a product. The user
enters the specification, hits enter, and the code below concentenates
the name of the spec, the value, and the prefix/suffix as required.
Multiple specs are strung together into a single memo field.
Everything works fine until the last record on the subform. The event
fires, but (I assume) because the last record does not lose the focus,
the value of the last spec is not updated in the concentenated memo
field.
If the code is run after focus is moved off the last spec, the spec
updates as it should.
Any thoughts on how to do this simply? I can't detect when enter is
used after updating the last record (as opposed to using enter on the
second last record, moving to the last record, and then firing the
enter event - which is what seems to happen naturally).
Thoughts? Code below sig line.
Regards,
Robin
Private Sub UpdateConcSpecs()
Dim db As Database
Dim rs As Recordset
Dim strSQL As String
Dim varConcat As Variant
'Concentenated specification proceedure
Set db = CurrentDb
strSQL = "SELECT AutoProductNumber, ConcValue FROM
qryProClassJoinDetails WHERE AutoProductNumber = " &
Eval("Forms.frmProductSpecifications.AutoProductNumber")
Set rs = db.OpenRecordset(strSQL, dbOpenSnapshot)
varConcat = Null
'Make sure records exist
With rs
If .RecordCount <> 0 Then
'start concatenating records
Do While Not rs.EOF
varConcat = varConcat & rs("ConcValue") & "<br> "
.MoveNext
Loop
End If
End With
Forms!frmProductSpecifications.ConcSpecDescription = varConcat
Exit_UpdateConcSpec:
Set rs = Nothing: Set db = Nothing
Exit Sub
Err_UpdateConcSpecs:
Resume Exit_UpdateConcSpec
enters the specification, hits enter, and the code below concentenates
the name of the spec, the value, and the prefix/suffix as required.
Multiple specs are strung together into a single memo field.
Everything works fine until the last record on the subform. The event
fires, but (I assume) because the last record does not lose the focus,
the value of the last spec is not updated in the concentenated memo
field.
If the code is run after focus is moved off the last spec, the spec
updates as it should.
Any thoughts on how to do this simply? I can't detect when enter is
used after updating the last record (as opposed to using enter on the
second last record, moving to the last record, and then firing the
enter event - which is what seems to happen naturally).
Thoughts? Code below sig line.
Regards,
Robin
Private Sub UpdateConcSpecs()
Dim db As Database
Dim rs As Recordset
Dim strSQL As String
Dim varConcat As Variant
'Concentenated specification proceedure
Set db = CurrentDb
strSQL = "SELECT AutoProductNumber, ConcValue FROM
qryProClassJoinDetails WHERE AutoProductNumber = " &
Eval("Forms.frmProductSpecifications.AutoProductNumber")
Set rs = db.OpenRecordset(strSQL, dbOpenSnapshot)
varConcat = Null
'Make sure records exist
With rs
If .RecordCount <> 0 Then
'start concatenating records
Do While Not rs.EOF
varConcat = varConcat & rs("ConcValue") & "<br> "
.MoveNext
Loop
End If
End With
Forms!frmProductSpecifications.ConcSpecDescription = varConcat
Exit_UpdateConcSpec:
Set rs = Nothing: Set db = Nothing
Exit Sub
Err_UpdateConcSpecs:
Resume Exit_UpdateConcSpec