473,414 Members | 1,980 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

Macro conditions not being executed, even when met.

118 100+
Hi folks,

I have a system for an auctioneer and have on the form I have the fields: lot (the item), reserve price ([Reserve]) and minimum successful bid so far ([Min]). There is then a text box for the user to input their bid ([Bid]). I have set up a macro for this:
Expand|Select|Wrap|Line Numbers
  1. mcr_addBid:
  2. Condition               Action           
  3. isNull([Lot])           MsgBox
  4. isNull([Lot])           Stop Macro
  5. isNull([Bid])           MsgBox
  6. isNull([Bid])           StopMacro
  7. [Bid]<=[Reserve]    MsgBox
  8. [Bid]<=[Reserve]    StopMacro
  9. [Bid]<=[Min]          MsgBox
  10. [Bid]<=[Min]          StopMacro
  11. [Bid]>[Min]            MsgBox
  12. [Bid]>[Min]            StopMacro
  13.  
at the moment I've only set it up for msg boxes to test it, but it works fine if either Lot or Bid is empty but then any value in bids doesn't run any of the latter actions, it's not that it gets stuck on one, it doesn't do any of them at all.

Am I doing something wrong with the conditions? (I obviously am doing something, but I don't know what).

Thanks,
Sam
May 16 '08 #1
11 2099
NeoPa
32,556 Expert Mod 16PB
Sam, I should warn you that, although some of our members do know a bit about using macros, it's very rarely used professionally.

Most of us use VBA exclusively in our projects.
May 16 '08 #2
NeoPa
32,556 Expert Mod 16PB
I did try to go through the logic of it and I found it difficult without any data posted.

Perhaps if you posted a set of data for all the controls you refer to and explain how it behaved when you tested with that data someone could see the problem more easily.
May 16 '08 #3
helraizer1
118 100+
Ok fair point.

Let's say I have a lot for a 1 bedroom apartment, when the user chooses this (from a combo box, 'Lot') the values of 'Min', 'Reserve' change accordingly.

So they choose 1 bedroom apartment and the value appears in Min as £109,400 and Reserve as £90,000.

There is then a text box for them to enter their bid in, which is named 'Bid'. When they press the "Make Bid!" button it should execute the macro. If there is no Lot selected they get an error message saying "Please choose a lot to bid for"; that works. If there is a Lot but no value in Bid, or the Bid is less than £1000 then they get an error message saying "Please enter a substantial bid"; that also works.

However as soon as they enter a number over 1000 nothing at all executes. Even if it's £1001 or £1,513,500.

Any ideas?
May 18 '08 #4
missinglinq
3,532 Expert 2GB
Like most here, I never use macros with the exception of AutoExec and AutoKeys, but the one thing I see glancing at this, and it relates to the portion of the macro that's bombing, is that you have a field named Min. Min is a Reserved Word in Access, and needs to be changed, whether it's causing your problem or not.

Linq ;0)>
May 18 '08 #5
NeoPa
32,556 Expert Mod 16PB
I did try to go through the logic of it and I found it difficult without any data posted.

Perhaps if you posted a set of data for all the controls you refer to and explain how it behaved when you tested with that data someone could see the problem more easily.
When I suggested this I had no idea you'd find it complicated.

I'm afraid your latest post leaves more questions than answers. I can't see any correlation between the figures and macro code on the one side and 1,000 on the other.

As before, a full set of data that makes sense would be really quite helpful when trying to guess what may be going wrong.
May 19 '08 #6
missinglinq
3,532 Expert 2GB
I keep reviewing this and like NeoPa, my head's swimming. One thought did occur to me; when comparing Numerical/Currency data and the comparisons fail to function as one would expect, one of the first thing to look at is the Datatypes of the data. Are you sure that all of your fields, bid, reserve and min (and you really need to change the name of min to something else) are either Currency or Numerical? Having one or more of them defined as Text would foul up the comaprison operations.

Linq ;0)>
May 19 '08 #7
helraizer1
118 100+
I usually do use VBA but for this I have to use Macros. The 1'000 part is using exactly the same macro only I have

Expand|Select|Wrap|Line Numbers
  1. IsNull([Bid]) Or [Bid]<1000
  2.  
Which works fine.

I think I've sorted the problem now though. The values for each field was found by a query linked to the rowsource of the fields. I've now made the Control source as DLookUp or DMin to get the same values. Now each step of the macro works.

Thanks for the help, guys.
May 19 '08 #8
NeoPa
32,556 Expert Mod 16PB
So the code you're actually testing with is different from the code you posted and we can see :S

Am I missing something here?

Clearly if you have any lines which check against a value of 1,000 then that's where you'd need to look for the logic flaw. We'd help, but it's not easy when you don't have the same code as you're testing with.
May 19 '08 #9
helraizer1
118 100+
You did have the same code I was testing, only with that 1 minor change, but as I said from the beginning that part of the code executed; with the <1000 or without it. So the problem was within the latter part, which you had exactly what I was using. =)

The row source/control source part has fixed it now so it works perfectly.

Sam
May 20 '08 #10
NeoPa
32,556 Expert Mod 16PB
I'd better get my degree in Mind-Reading sorted out then I suppose :(
May 20 '08 #11
missinglinq
3,532 Expert 2GB
Like I've said to OPs before, the fact that many of us here are out of our minds doesn't mean that we're in their minds!

I guess we need to get MS Access-Ouija Board Edition!

Linq ;0)>
May 20 '08 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Comcast Newsgroups | last post by:
I'm trying to put together a macro that queries my cell phone call expense DB the selects records as of a specific Date that are not marked "Archive", prints a report, then marks the records...
7
by: Newbie_sw2003 | last post by:
Where should I use them? I am giving you my understandings. Please correct me if I am wrong: MACRO: e.g.:#define ref-name 99 The code is substituted by the MACRO ref-name. So no overhead....
7
by: Tobin Fricke | last post by:
I have a wrapper function I use to check the error conditions of various functions: wrap(foo(1,2,3)); (1) while (1 == wrap(bar("fluffy"))) { ... } (2)...
13
by: uma676 | last post by:
Hi all, I want to know the differebces between function and macro in c language. if anybody can tell me atleast 4 diff's. for which i will be regrated. Rgds, Balaji
1
by: Jo | last post by:
I am having a real problem with the Launch conditions in VS .NET and can only come to the conclusion that it is a bug. It states quite emphatically in the MSDN that Launch Conditions WILL be...
5
by: Bill | last post by:
This database has no forms. I am viewing an Access table in datasheet view. I'd like to execute a macro to execute a function (using "runcode"). In the function, I'll reading data from the record...
3
by: swb76 | last post by:
Hi, I have 6 queries in Access that run great. They need to be run in sequence with the first 5 queries writing to tables and the sixth one pops up the final results in datasheet view. Now, how...
3
MMcCarthy
by: MMcCarthy | last post by:
Although some users find Macros simple and easy to use, there are some major limitations to using them. Although you can use macros to perform tasks, there is limited control on when and how those...
5
by: Peng Yu | last post by:
Hi, It is benifitical to use macro in certain cases. http://www.boost.org/doc/libs/1_35_0/libs/preprocessor/doc/index.html However, I found that it is not easy to debug a macro. For example,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.