Page 2 of 2 FirstFirst 12
Results 16 to 17 of 17
  1. #16
    TOMMY.MYERS668's Avatar
    TOMMY.MYERS668 is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Feb 2013
    Location
    West Virginia
    Posts
    77

    Dlookup issue

    I just attatched it because im sure my logic is mostly screwy but the issue im having is at the very bottom of the code on the info entry form it looks liek this:
    Private Sub Weight_AfterUpdate()
    Dim agebracket As String
    Dim age As Integer

    'calculate age
    age = DateDiff("yyyy", Me![DOB], Date) - IIf(Format$(Date, "mmdd") < Format$(Me![DOB], "mmdd"), 1, 0)
    ' HEY MACARENA!!!!!
    Me![age now] = age
    'calculate bracket
    If age >= 17 And age < 21 Then
    If Me![male female] = "MALE" Then
    agebracket = "male age bracket 17 to 20"
    Else
    agebracket = "female age bracket 17 to 20"
    End If
    Else
    If age >= 21 And age < 27 Then
    If Me![male or female] = "MALE" Then
    agebracket = "male age bracket 21 to 27"
    Else
    agebracket = "female age bracket 21 to 27"
    End If
    Else


    If age >= 28 And age < 39 Then
    If Me![male or female] = "MALE" Then
    agebracket = "male age bracket 28 to 39"
    Else
    agebracket = "female age bracket 28 to 39"
    End If
    Else
    If age >= 40 Then
    If Me![male or female] = "MALE" Then
    agebracket = "male age bracket 40 plus"
    Else
    agebracket = "female age bracket 40 plus"
    End If
    End If
    End If
    End If
    End If
    Me![agebracketpull] = agebracket
    Me![max weight] = DLookup("&Me![agebracketpull]&", "[height weight table]", "[height] =", " & Me![Height] & ")


    End Sub

    so as you can see the [agebracketpull] is a string variabel not the actual name of the field on the table... the string in it is the field on the table however. and hight is a number not text but my fields on the table are also number.
    Attached Files Attached Files

  2. #17
    TOMMY.MYERS668's Avatar
    TOMMY.MYERS668 is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Feb 2013
    Location
    West Virginia
    Posts
    77

    Re: Age calc wrong.

    I got it it was:
    Dlookup ("[" [agebracketpull]"]", then the rest

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Calc
    By hitman in forum Access
    Replies: 2
    Last Post: 02-14-2013, 07:10 AM
  2. Replies: 1
    Last Post: 06-04-2012, 07:17 PM
  3. Iff query with date calc?
    By technet in forum Queries
    Replies: 3
    Last Post: 02-08-2012, 10:17 AM
  4. calc field
    By nashr1928 in forum Forms
    Replies: 8
    Last Post: 11-09-2011, 09:21 PM
  5. Calc fields
    By nashr1928 in forum Forms
    Replies: 5
    Last Post: 02-26-2011, 08:35 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums