C Cpar Registered User. Local time Today, 01:40 Joined Jan 9, 2016 Messages 41 Feb 19, 2016 #1 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
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
C CJ_London Super Moderator Staff member Local time Today, 07:40 Joined Feb 19, 2013 Messages 17,563 Feb 19, 2016 #2 between do not work in vba - use >= and <= e,g, myvalue>=x and myvalue<=y
Y yupstrips01 Registered User. Local time Today, 12:10 Joined Mar 31, 2016 Messages 19 May 12, 2016 #3 thanks for sharing this post, its helping me
isladogs MVP / VIP Local time Today, 07:40 Joined Jan 14, 2017 Messages 19,010 Oct 26, 2017 #4 CJ_London said: between do not work in vba - use >= and <= e,g, myvalue>=x and myvalue<=y Click to expand... 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!
CJ_London said: between do not work in vba - use >= and <= e,g, myvalue>=x and myvalue<=y Click to expand... 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!
C CJ_London Super Moderator Staff member Local time Today, 07:40 Joined Feb 19, 2013 Messages 17,563 Oct 26, 2017 #5 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...
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...
isladogs MVP / VIP Local time Today, 07:40 Joined Jan 14, 2017 Messages 19,010 Oct 26, 2017 #6 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 Last edited: Oct 26, 2017
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