UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Macro, If Then Openquery, Access 2016    
 
   
New2U
post Mar 28 2019, 12:33 PM
Post#1



Posts: 2
Joined: 27-March 19



I'll state right up front, I'm a newbie to Access and programming. I've done much reading and videos to learn Access 2016, and am finding building an Access database fun and challenging. However, building a Macro for an If Then scenario is proving to be tricky.
I'm trying to set up the Macro so that if condition one is is true, then perform a calculation and populate the results into a table, if false, go to the second condition, if true perform the calculation and insert the result into a table, and so forth with the other conditions.

If [tbl_InvPrelambda].[HSH2] = “H2” And [tbl_InvPrelambda].[NbrProbes] <≠ 15000, Then 80 * [tbl_InvPrelambda].[NbrProbes] / 1000000 = uM desired concentration
ElseIf [tbl_InvPrelambda].[HSH2] = “H2” And [tbl_InvPrelambda].[NbrProbes] ≥ 15000, Then 8 * [tbl_InvPrelambda].[NbrProbes] / 1000000 = uM desired concentration
ElseIf [tbl_InvPrelambda].[HSH2] = “HS” And [tbl_InvPrelambda].[NbrProbes] <≠ 20000, Then 240 * [tbl_InvPrelambda].[NbrProbes] / 1000000 = uM desired concentration
ElseIf [tbl_InvPrelambda].[HSH2] = “HS” And [tbl_InvPrelambda].[NbrProbes] ≥ 20000, Then 24 * [tbl_InvPrelambda].[NbrProbes] / 1000000 = uM desired concentration

What I have tried is creating a macro starting each condition with an If statement that if true runs a query. See attachment. When I run the macro, nothing happens. Some direction would be most appreciated. :-) I haven'nt added to the macro a way to populate the result to a table yet, as I'm still trying to figure that out also.

Attached File(s)
Attached File  IfThenElseIfRunQuery.jpg ( 83.46K )Number of downloads: 6
 
Go to the top of the page
 
theDBguy
post Mar 28 2019, 12:47 PM
Post#2


Access Wiki and Forums Moderator
Posts: 76,079
Joined: 19-June 07
From: SunnySandyEggo


Hi,

Welcome to UtterAccess!
welcome2UA.gif

I don't usually use macros but if you're trying to troubleshoot yours, maybe you could turn on Single Step to walk through your code. I think it's on the Ribbon menu when you're in the macro design view.

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
MadPiet
post Mar 28 2019, 12:57 PM
Post#3



Posts: 3,221
Joined: 27-February 09



If you're doing an update, you could create several simple queries and solve the problem one piece at a time, then call them in sequence in a single macro (not that I ever use macros, but still!)
Go to the top of the page
 
New2U
post Mar 29 2019, 11:35 AM
Post#4



Posts: 2
Joined: 27-March 19



Thank you for the reply. I'll give the Singly Step a go.
Go to the top of the page
 
theDBguy
post Mar 29 2019, 11:48 AM
Post#5


Access Wiki and Forums Moderator
Posts: 76,079
Joined: 19-June 07
From: SunnySandyEggo


Good luck. Let us know how it goes...

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    24th August 2019 - 12:25 AM