Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update SubForm Field Values From a Function

Status
Not open for further replies.

RoseV

Programmer
Mar 18, 2003
37
US
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 <> &quot;&quot; Then
UPC = RS!UPC
End If
If RS!CS <> &quot;&quot; Then
CS = RS!CS
End If
Else
UPC = &quot; &quot;
CS = &quot; &quot;
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
 
In case anyone can benefit from this:
What I did was make the 1st combo box have 4 columns show. Only the first is bound. Then on the change event for the combo box, I update the 1st field to the 1st unbound column, the next to the 2nd unbound...etc. It's much easier than what I was trying to do...and more importantly, it works!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top