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!

On Change event behind form

Status
Not open for further replies.

RoseV

Programmer
Mar 18, 2003
37
US
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 <> &quot;N/A&quot; Then
'ad name was selected - get sale price based on CS
Call GetAdPricesCS
End If

End Sub
 
RoseV

You want to have the code in that combo box's AfterUpdate property. The code would be something like, where &quot;Me&quot; = [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.

Jim DeGeorge [wavey]
 
I tried your suggestion, but it did not solve my problem - I get the same error.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top