On the change event for a set of three combo boxes, I want to evaluate the one that was entered and then update the other two. I have to put the evaluation procedure in a function, but am having trouble then updating the subform from the code in the function. Is there some special reference I have to set to update the subform rather than just the form? This is what I have:
Private Sub CboKras_Change()
Call GetKras(Me!CboKras.Value)
Me!CboUPC.Value = UPC
Me!CboCS.Value = CS
*** Here Access tells me that UPC and CS are null values
even when the GetKras populates the public variables.
End Sub
***MODULE
Public RS As Recordset
Public Kras As String
Public UPC As String
Public CS As String
Function GetKras(KrasVal)
Set RS = CurrentDb.OpenRecordset("SELECT..."
RS.MoveFirst
Do Until RS!Kras = KrasVal
If Not RS.EOF Then
RS.MoveNext
If RS!UPC <> "" Then
UPC = RS!UPC
End If
If RS!CS <> "" Then
CS = RS!CS
End If
Else
UPC = " "
CS = " "
Exit Do
End If
Loop
Forms!FrmOrderSub!CboUPC.Value = UPC
Forms!FrmOrderSub!CboCS.Value = CS
*** Here Access tells me that it can’t find the form
FrmOrderSub. The form and subform are open at this point
End Function
Private Sub CboKras_Change()
Call GetKras(Me!CboKras.Value)
Me!CboUPC.Value = UPC
Me!CboCS.Value = CS
*** Here Access tells me that UPC and CS are null values
even when the GetKras populates the public variables.
End Sub
***MODULE
Public RS As Recordset
Public Kras As String
Public UPC As String
Public CS As String
Function GetKras(KrasVal)
Set RS = CurrentDb.OpenRecordset("SELECT..."
RS.MoveFirst
Do Until RS!Kras = KrasVal
If Not RS.EOF Then
RS.MoveNext
If RS!UPC <> "" Then
UPC = RS!UPC
End If
If RS!CS <> "" Then
CS = RS!CS
End If
Else
UPC = " "
CS = " "
Exit Do
End If
Loop
Forms!FrmOrderSub!CboUPC.Value = UPC
Forms!FrmOrderSub!CboCS.Value = CS
*** Here Access tells me that it can’t find the form
FrmOrderSub. The form and subform are open at this point
End Function