If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Access > IF Between ?????

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-06-04, 08:00
bigmantone bigmantone is offline
Registered User
 
Join Date: Jun 2004
Location: United Kingdom
Posts: 3
IF Between ?????

Hi All,

I am trying to write code that can execute an id satement between 2 variables?????

please can anyone help?...any help most appreciated

function update()

Dim db As Database
Dim rec As Recordset
Set db = CurrentDb
Set rec = db.OpenRecordset("Table1")


Dim lot1 As Integer
Dim lot2 As Integer
Dim sd1 As Date

lot1 = [Text16].Value
lot2 = [Text17].Value
sd1 = [Text14].Value

Do While Not rec.EOF

rec.Edit


If rec("Lot no").value is between lot1 AND lot2 then ' this is where i am lost
rec("Date") = sd1

end if



rec.update

rec.MoveNext

Loop

update = True


End Function

Reply With Quote
  #2 (permalink)  
Old 06-06-04, 08:16
r123456 r123456 is offline
Registered User
 
Join Date: Sep 2003
Location: The extremely Royal borough of Kensington, London
Posts: 778
The between keyword is SQL and not VBA.

To implement x BETWEEN (a & b) in VBA:

If (x >= a) AND (x <= b) Then

End If
__________________
Bessie Braddock: Winston, you are drunk!
Churchill: And Madam, you are ugly. And tomorrow, I'll be sober, and you will still be ugly.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On