Go Back   Access World Forums > Microsoft Access Discussion > Modules & VBA

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 01-25-2019, 06:29 AM   #1
manosalexo
Newly Registered User
 
Join Date: Jan 2019
Location: Athens, Greece
Posts: 6
Thanks: 4
Thanked 0 Times in 0 Posts
manosalexo is on a distinguished road
If i call another AfterUpdate i get a 3075 error

Hello,

I have a situation.
I have built a form in which at the product's afterupdate event i have inserted the following:

Private Sub Product_AfterUpdate()
Me.Category = DLookup("[Category_table.Description]", "Query3", "[product_id]=" & Forms!order!Product)
Me.plaisio_idd = DLookup("[plaisio_id]", "Products", "[product_id]=" & Forms!order!Product)
Me.color_description = Null
Me.color_description.Requery
Me.color_description = DLookup("[color_description]", "Query1", "[product_id]=" & Forms!order!Product)
Me.Price = DLookup("[price]", "Products", "[product_id]=" & Forms!order!Product)
Me.measurement_unit = DLookup("[measurement_unit]", "Products", "[product_id]=" & Forms!order!Product)
End Sub

Now what i am trying to do is to Call that event from another afterupdate so that the user may either select the product, or enter the ID:
Private Sub plaisio_idd_AfterUpdate()
Me.Product.Requery
Me.Product = DLookup("[description]", "[Products]", "[plaisio_id]=" & Forms!order!plaisio_idd)
Call Product_AfterUpdate
End Sub

Now when i insert these lines of code, the debugger hits a 3075 error in my Product_AfterUpdate() code. If i remove plaisio_idd_AfterUpdate(), my Product_AfterUpdate works just fine.

Can someone please tell me what i'm doing wrong?
Thank you in advance

manosalexo is offline   Reply With Quote
Old 01-25-2019, 06:39 AM   #2
Ranman256
Newly Registered User
 
Join Date: Apr 2015
Location: KY,USA
Posts: 3,368
Thanks: 0
Thanked 742 Times in 727 Posts
Ranman256 will become famous soon enough Ranman256 will become famous soon enough
Re: If i call another AfterUpdate i get a 3075 error

why are you doing 3 things here? :

Me.color_description = Null
Me.color_description.Requery
Me.color_description = DLookup("[color_description]", "Query1", "[product_id]=" & Forms!order!Product)

just do 1.
Ranman256 is offline   Reply With Quote
The Following User Says Thank You to Ranman256 For This Useful Post:
manosalexo (01-25-2019)
Old 01-25-2019, 06:45 AM   #3
The_Doc_Man
Happy Retired Curmudgeon
 
Join Date: Feb 2001
Location: Suburban New Orleans, LA, USA
Posts: 14,540
Thanks: 92
Thanked 1,680 Times in 1,559 Posts
The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold
Re: If i call another AfterUpdate i get a 3075 error

Make that section of the Product_AfterUpdate() code that is relevant into a separate subroutine in the class module. If you have trouble because of the use of "Me" in the routine, make it have a formal parameter that is an Access form. Then call the subroutine from both events with "Me" as an argument.

Code:
Private Sub SelectOrChange( F as Access.Form )
  F.Category = Dlookup( "F.[Category_table.Descripton]", "Query3", "[Product_ID]=...etc
  F.Color_Description = Null
... etc.
End
Use F in the subroutine whenever you refer to a control on that form. (In your second event sub, the "Me" references outside the new subroutine do not change), call it with

Code:
    Call SelectOrChange( Me )

__________________
I'm a certified grandpa (3 times now) and proud of it.
Retired over one year and survived being home all day with the wife. She must really love me.
If I have helped you, please either click the thanks or click the scales.
The_Doc_Man is offline   Reply With Quote
The Following User Says Thank You to The_Doc_Man For This Useful Post:
manosalexo (01-29-2019)
Old 01-25-2019, 06:46 AM   #4
manosalexo
Newly Registered User
 
Join Date: Jan 2019
Location: Athens, Greece
Posts: 6
Thanks: 4
Thanked 0 Times in 0 Posts
manosalexo is on a distinguished road
Re: If i call another AfterUpdate i get a 3075 error

Quote:
Originally Posted by Ranman256 View Post
why are you doing 3 things here? :

Me.color_description = Null
Me.color_description.Requery
Me.color_description = DLookup("[color_description]", "Query1", "[product_id]=" & Forms!order!Product)

just do 1.
You're right, changed that but the problem still remains
manosalexo is offline   Reply With Quote
Old 01-26-2019, 10:11 PM   #5
Pat Hartman
Super Moderator
 
Join Date: Feb 2002
Location: Stratford,Ct USA
Posts: 28,249
Thanks: 15
Thanked 1,591 Times in 1,511 Posts
Pat Hartman is a name known to all Pat Hartman is a name known to all Pat Hartman is a name known to all Pat Hartman is a name known to all Pat Hartman is a name known to all Pat Hartman is a name known to all
Re: If i call another AfterUpdate i get a 3075 error

There are better ways to do this. I've attached a sample database that shows a better solution.
Attached Files
File Type: zip FillFormFields20180816.zip (342.4 KB, 14 views)
__________________
Bridge Players Still Know All the Tricks
Pat Hartman is offline   Reply With Quote
The Following User Says Thank You to Pat Hartman For This Useful Post:
manosalexo (01-28-2019)
Old 01-28-2019, 11:35 PM   #6
manosalexo
Newly Registered User
 
Join Date: Jan 2019
Location: Athens, Greece
Posts: 6
Thanks: 4
Thanked 0 Times in 0 Posts
manosalexo is on a distinguished road
Re: If i call another AfterUpdate i get a 3075 error

Quote:
Originally Posted by The_Doc_Man View Post
Make that section of the Product_AfterUpdate() code that is relevant into a separate subroutine in the class module. If you have trouble because of the use of "Me" in the routine, make it have a formal parameter that is an Access form. Then call the subroutine from both events with "Me" as an argument.

Code:
Private Sub SelectOrChange( F as Access.Form )
  F.Category = Dlookup( "F.[Category_table.Descripton]", "Query3", "[Product_ID]=...etc
  F.Color_Description = Null
... etc.
End
Use F in the subroutine whenever you refer to a control on that form. (In your second event sub, the "Me" references outside the new subroutine do not change), call it with

Code:
    Call SelectOrChange( Me )
Tried it and the problem appears at the "F." declarations section this time.

update: It now shows run-time error 3126

Last edited by manosalexo; 01-28-2019 at 11:42 PM.
manosalexo is offline   Reply With Quote
Old 01-28-2019, 11:37 PM   #7
manosalexo
Newly Registered User
 
Join Date: Jan 2019
Location: Athens, Greece
Posts: 6
Thanks: 4
Thanked 0 Times in 0 Posts
manosalexo is on a distinguished road
Re: If i call another AfterUpdate i get a 3075 error

Quote:
Originally Posted by Pat Hartman View Post
There are better ways to do this. I've attached a sample database that shows a better solution.
Thank you very much for your help!


manosalexo is offline   Reply With Quote
Reply

Tags
after update , dlookup access forms , error 3075

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Run time error '3075': Syntax error (missing operator) in query expression manusri Modules & VBA 9 02-16-2017 05:45 PM
Question strSQL = Run Time Error 3075 Syntax Error Missing Operator in qry Expr maxsun08 General 4 07-27-2012 06:39 AM
Run time error 3075 - syntax error (missing operator) in query expression puskardas Modules & VBA 8 06-30-2008 07:35 PM
Call Call Audit_Trail Ambigious Error fenhow Modules & VBA 6 07-27-2007 08:26 AM
Call AfterUpdate of a Control modest Modules & VBA 3 12-11-2005 04:33 PM




All times are GMT -8. The time now is 04:14 AM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World