Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2004
    Location
    United Kingdom
    Posts
    3

    Unanswered: 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


  2. #2
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •