Please help!
I have this combo Box and use this code to populate to other fields:
Private Sub ServiceCode_Exit(Cancel As Integer)
Dim varSerC, varDiag, varRate As Variant
varSerC = DLookup("ServiceCode", "Service List", "ServiceCode = [ServiceCode] ")
varDiag = DLookup("Diagnosis", "Service List", "ServiceCode = [ServiceCode] ") & " - " & DLookup("ServiceTitle", "Service List", "ServiceCode = [ServiceCode] ")
varRate = DLookup("Rate", "Service List", "ServiceCode = [ServiceCode] ")
If (Not IsNull(varSerC)) Then Me![ServiceCode] = varSerC
If (Not IsNull(varDiag)) Then Me![Diagnosis] = varDiag
If (Not IsNull(varRate)) Then Me![Rate] = varRate
End Sub
But when the form is opened and the the ServiceCode is picked from the Combo Box, the first record is always selected and populated to the other fields. Whereas, the SerID populates correctly.
Where am I going wrong? Please look me up.
I have this combo Box and use this code to populate to other fields:
Private Sub ServiceCode_Exit(Cancel As Integer)
Dim varSerC, varDiag, varRate As Variant
varSerC = DLookup("ServiceCode", "Service List", "ServiceCode = [ServiceCode] ")
varDiag = DLookup("Diagnosis", "Service List", "ServiceCode = [ServiceCode] ") & " - " & DLookup("ServiceTitle", "Service List", "ServiceCode = [ServiceCode] ")
varRate = DLookup("Rate", "Service List", "ServiceCode = [ServiceCode] ")
If (Not IsNull(varSerC)) Then Me![ServiceCode] = varSerC
If (Not IsNull(varDiag)) Then Me![Diagnosis] = varDiag
If (Not IsNull(varRate)) Then Me![Rate] = varRate
End Sub
But when the form is opened and the the ServiceCode is picked from the Combo Box, the first record is always selected and populated to the other fields. Whereas, the SerID populates correctly.
Where am I going wrong? Please look me up.
0 commentaires:
Enregistrer un commentaire