Go Back   Access World Forums > Apps and Windows > Visual Basic

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 02-18-2016, 05:16 PM   #1
Cpar
Newly Registered User
 
Join Date: Jan 2016
Posts: 41
Thanks: 1
Thanked 0 Times in 0 Posts
Cpar is on a distinguished road
Should not be to hard of a question

I am having trouble with vba code for between. Such as if this box has a value within .11 and .25 then return "different control source" with "A". Like I said should be a simple enough question. I do not know why I can not get it. Thanks in advance

Cpar is offline   Reply With Quote
Old 02-18-2016, 06:09 PM   #2
CJ_London
Super Moderator
 
Join Date: Feb 2013
Location: UK
Posts: 10,008
Thanks: 38
Thanked 3,241 Times in 3,139 Posts
CJ_London is just really nice CJ_London is just really nice CJ_London is just really nice CJ_London is just really nice
Re: Should not be to hard of a question

between do not work in vba - use >= and <= e,g,

myvalue>=x and myvalue<=y
__________________
CJ_London
_______________________
A little thanks goes a long way. If you have found this post useful, please tick the thanks button
CJ_London is offline   Reply With Quote
Old 05-12-2016, 02:33 AM   #3
yupstrips01
Newly Registered User
 
Join Date: Mar 2016
Posts: 19
Thanks: 0
Thanked 2 Times in 2 Posts
yupstrips01 is on a distinguished road
Re: Should not be to hard of a question

thanks for sharing this post, its helping me

yupstrips01 is offline   Reply With Quote
Old 10-26-2017, 02:32 AM   #4
ridders
Newbee moderator
Gold Supporter
 
ridders's Avatar
 
Join Date: Jan 2017
Location: Somerset, UK
Posts: 5,530
Thanks: 79
Thanked 1,368 Times in 1,277 Posts
ridders is a jewel in the rough ridders is a jewel in the rough ridders is a jewel in the rough ridders is a jewel in the rough
Re: Should not be to hard of a question

Quote:
Originally Posted by CJ_London View Post
between do not work in vba - use >= and <= e,g,

myvalue>=x and myvalue<=y
Sorry but this isn't true
The following 2 SQL statements do EXACTLY the same thing

Code:
DoCmd.RunSQL "UPDATE SchConstants SET SchConstants.[Value] = Null" & _
        " WHERE (((SchConstants.ConstantID) Between 76 And 81));"
Code:
DoCmd.RunSQL "UPDATE SchConstants SET SchConstants.[Value] = Null" & _
        " WHERE (((SchConstants.ConstantID)>=76 And (SchConstants.ConstantID)<=81));"
I find the first version easier to use and less typing!
__________________
Colin
Access 2010 32-bit, Access 2016 32-bit & 64-bit, SQL Server Express 2014, Windows 10,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


If this answer has helped, please click the Thanks button and/or click the 'reputation scales' symbol on the left and leave a comment.

New example databases:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


-------------------------
nil illegitimi carborundum est
ridders is offline   Reply With Quote
Old 10-26-2017, 03:03 AM   #5
CJ_London
Super Moderator
 
Join Date: Feb 2013
Location: UK
Posts: 10,008
Thanks: 38
Thanked 3,241 Times in 3,139 Posts
CJ_London is just really nice CJ_London is just really nice CJ_London is just really nice CJ_London is just really nice
Re: Should not be to hard of a question

this is an old question, but it was not to do with writing a sql statement in VBA (in which case I agree with you) but using VBA e.g.

if X between 1 and 3 then...
__________________
CJ_London
_______________________
A little thanks goes a long way. If you have found this post useful, please tick the thanks button
CJ_London is offline   Reply With Quote
Old 10-26-2017, 05:12 AM   #6
ridders
Newbee moderator
Gold Supporter
 
ridders's Avatar
 
Join Date: Jan 2017
Location: Somerset, UK
Posts: 5,530
Thanks: 79
Thanked 1,368 Times in 1,277 Posts
ridders is a jewel in the rough ridders is a jewel in the rough ridders is a jewel in the rough ridders is a jewel in the rough
Re: Should not be to hard of a question

Hi Chris

I responded when the thread was resurrected by rebeccajr
EDIT: rebeccajr's posts have since been deleted...!

Anyway - that wasn't how I read the thread.
You are of course absolutely correct for IF statements

This works
Code:
If X>=1 And X<=5 Then MsgBox "The value of X = " & X
but this doesn't
Code:
If X Between 1 And 5 Then MsgBox "The value of X = " & X
Cheers

__________________
Colin
Access 2010 32-bit, Access 2016 32-bit & 64-bit, SQL Server Express 2014, Windows 10,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


If this answer has helped, please click the Thanks button and/or click the 'reputation scales' symbol on the left and leave a comment.

New example databases:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


-------------------------
nil illegitimi carborundum est

Last edited by ridders; 10-26-2017 at 06:54 AM.
ridders is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Hard Question chivo123 General 2 01-23-2012 06:38 AM
A REALLY hard Query Question ccflyer Queries 12 08-15-2005 08:01 AM
Hard Question mahmudich General 3 02-14-2003 07:05 AM
This is a HARD QUESTION!!!! DaniBoy General 8 07-18-2002 07:10 AM
footers - hard question sullivan Reports 3 01-04-2002 06:37 AM




All times are GMT -8. The time now is 12:01 PM.


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

Sponsored Links

How to advertise

Media Kit


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