...error occurs because a macro or event name is expected to run when the event occurs

ExcelChampion

Well-known Member
Joined
Aug 12, 2005
Messages
976
I cannot figure out the solution to this error:

PHP:
This error occurs when an event has failed to run because the location of the logic for the event cannot be evaluated. For example, if the OnOpen property of a form is set to =[Field], this error occurs because a macro or event name is expected to run when the event occurs.

Code:
Option Compare Database

Private Sub Text2_AfterUpdate()
   
    If (Text2 & vbNullString) = vbNullString Then Exit Sub

    Text2 = UCase(Replace(Replace(Replace(Replace(Replace(Text2, "-", ""), " ", ""), ".", ""), "(", ""), ")", ""))

    Me.Controls("qry_1804_Main_Item_Detail subform").Form.FilterOn = True
    Me.Controls("qry_1804_Main_Item_Detail subform").Form.Filter = "ID = Text2"

    Me.Controls("qry_1804_Main_Manuf_Detail subform").Form.FilterOn = True
    Me.Controls("qry_1804_Main_Manuf_Detail subform").Form.Filter = "ID = Text2"
    
End Sub

Using Access 2010. This code worked in earlier versions (with a Dim and Ref to DAO.) But, now, I have no idea what Refs I should have, if any. I have the default ones plus added the Access database engine. I have no clue what to do and can't find an answer.

Man, I can't stand this version of Office....nothing wants to work anynmore that's worked forever...

Thanks for the help.

Todd
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
I too hate EVERYTHING about the new Access. Over a dozen things I use in the old one, are gone. Hate it.

NOW...
your filter is off due to the code unable to resolve TEXT2. You have it 'hardcoded' in the filter so it wont get the contents of Text2. Text2 must be outside the quotes.
Me.Controls("qry_1804_Main_Manuf_Detail subform").Form.Filter = "ID = " & Text2
 
Upvote 0

Forum statistics

Threads
1,214,833
Messages
6,121,862
Members
449,052
Latest member
Fuddy_Duddy

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top