Solved Error 2766 when executing a MACRO with IF condition (1 Viewer)

kamaldoctor

New member
Local time
Today, 06:08
Joined
May 4, 2013
Messages
13
Hi, I am trying to write If condition in a Macro to execute query. Following condition gives me Error 2766
[MaxHorseRatingTable]![centre]=DEL
centre is a TEXT field
Please Guide.
Thanks & Regards
Kamal Doctor
 

theDBguy

I’m here to help
Staff member
Local time
Today, 06:08
Joined
Oct 29, 2018
Messages
21,288
Can you show us the actual code from your macro (screenshot)?
 

kamaldoctor

New member
Local time
Today, 06:08
Joined
May 4, 2013
Messages
13
2023-11-06.png
 

kamaldoctor

New member
Local time
Today, 06:08
Joined
May 4, 2013
Messages
13
Thanks! By the way, what is the error message for error number 2766?

If [DEL] is a Text Field, where/how are you executing this macro? If from a form, is DEL a Textbox on that form?
This is from a Table having Field Name as centre which is a Text field
 

kamaldoctor

New member
Local time
Today, 06:08
Joined
May 4, 2013
Messages
13
Thanks! By the way, what is the error message for error number 2766?

If [DEL] is a Text Field, where/how are you executing this macro? If from a form, is DEL a Textbox on that form?
Macro is being run from Access Switchboard Manager. There are 9 different Horse Racing Centres in India. I want to run 1 set of Queries when [centre] is "DEL" or "OOT". For rest of the [centre]s I want to run Else set of queries. The entire Macro will be pertaining to only 1 centre at a time.
 
Last edited:

Minty

AWF VIP
Local time
Today, 14:08
Joined
Jul 26, 2013
Messages
10,327
I don't think a Macro will have any knowledge of a tables data in that way, how would it know which record you where on?
You would need to have that fields data available on a form to make that type of switch work.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 06:08
Joined
Oct 29, 2018
Messages
21,288
Macro is being run from Access Switchboard Manager. There are 9 different Horse Racing Centres in India. I want to run 1 set of Queries when [centre] is "DEL" or "OOT". For rest of the [centre]s I want to run Else set of queries. The entire Macro will be pertaining to only 1 centre at a time.
Try using DLookup() to fetch the data from the table.
 

kamaldoctor

New member
Local time
Today, 06:08
Joined
May 4, 2013
Messages
13
Hi Everyone,
Thanks for looking at my problem and offering your valuable suggestions.
My issue is RESOLVED by preparing a Form with [centre] Field. Macro works perfectly.
Many Thanks & Regards,
Kamal Doctor
 

Users who are viewing this thread

Top Bottom