I have 3 combo boxes that are linked together. When anyone of them is changed or populated, I want Access to automatically populate the other 2 fields. I've tried ALL the options; OnChange, OnDirty, OnUpdate, AfterUpdate...all of them. The event procedure is in a Private Sub and what I'm doing is checking the value the user selected from the combo box and determining what the other two are. There is similar code in each event procedure. No matter what I do, I keep getting an error when I populate or change the value in any of the boxes - the error about not being able to evaluate the function or macro; The Expression AfterUpdate (or whatever I try)...produced the following error: Procedure Declaration does not match description of event or procedure having the same name. Blah, blah, blah. What am I missing here??
Private Sub CboCS_AfterUpdate()
(RS and all variables declared publicly)
Set RS = CurrentDb.OpenRecordset("SELECT TblItems.CS, TblItems.UPC, TblItems.Kras FROM TblItems GROUP BY TblItems.CS, TblItems.UPC, TblItems.Kras ORDER BY TblItems.CS;"
RS.MoveFirst
CCode = Me!CboCS.Value
Do Until RS!CS = CCode
If Not RS.EOF Then
RS.MoveNext
Else
Me!CboUPC.Value = RS!UPC
Me!CboKras.Value = RS!Kras
End If
Loop
'check if an AdName was selected
If Forms!frmorders!TxtAdName.Value <> "N/A" Then
'ad name was selected - get sale price based on CS
Call GetAdPricesCS
End If
End Sub
This was suggested:
RoseV
You want to have the code in that combo box's AfterUpdate property. The code would be something like, where "Me" = [name of 2nd CBO]:
Me.[name of 2nd CBO field].SetFocus
Me.[name of 2nd CBO field] = DLookup(etc., based on value of CBO1).
Hope this helps
*But it did not help. I get the same message. Do I need to set an additional reference in the modules? I can't figure this out. Anybody have any other ideas??
Private Sub CboCS_AfterUpdate()
(RS and all variables declared publicly)
Set RS = CurrentDb.OpenRecordset("SELECT TblItems.CS, TblItems.UPC, TblItems.Kras FROM TblItems GROUP BY TblItems.CS, TblItems.UPC, TblItems.Kras ORDER BY TblItems.CS;"
RS.MoveFirst
CCode = Me!CboCS.Value
Do Until RS!CS = CCode
If Not RS.EOF Then
RS.MoveNext
Else
Me!CboUPC.Value = RS!UPC
Me!CboKras.Value = RS!Kras
End If
Loop
'check if an AdName was selected
If Forms!frmorders!TxtAdName.Value <> "N/A" Then
'ad name was selected - get sale price based on CS
Call GetAdPricesCS
End If
End Sub
This was suggested:
RoseV
You want to have the code in that combo box's AfterUpdate property. The code would be something like, where "Me" = [name of 2nd CBO]:
Me.[name of 2nd CBO field].SetFocus
Me.[name of 2nd CBO field] = DLookup(etc., based on value of CBO1).
Hope this helps
*But it did not help. I get the same message. Do I need to set an additional reference in the modules? I can't figure this out. Anybody have any other ideas??