Results 1 to 3 of 3
  1. #1
    Lounger
    Join Date
    May 2004
    Location
    Pardeeville, Wisconsin, USA
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I am trying to write an If…then…else statement based on a check box entry that looks up the value in another table. This value is then entered into the text box.

    If UpgradeBusinessCard is checked (true) then look up the UpgradePrice based on the year in the UpGradePrice_TBL

    Both my form (ExhibitorCntrct_Booth subform) and table (UpGradePrice_TBL) have a year field., that I want to match to find the UpgradePrice for that year. (This is something that may change in the future, but I want to be able to track the old rate.)

    Private Sub UpgradePrice_GotFocus()
    If Me.UpgradeBusinessCard = True Then
    Me.Year = Form!UpGradePrice_TBL!Year

    Me.UpgradePrice = Form!UpGradePrice_TBL!UpgradePrice
    Else: Me.UpgradePrice = 0
    End If

    End Sub

    This is not working, but I am not getting any error messages either even with my breakPoints set. As you can tell my coding skills are weak, but I am eager to learn. Thank you very much for your assistance.

    Delta♠

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    I'm not sure I understand what you want, but can't refer to a table as Form!...
    Try this:

    Code:
    Private Sub UpgradePrice_GotFocus()
      If Me.UpgradeBusinessCard = True Then
    	Me.UpgradePrice = DLookup("UpgradePrice", "UpGradePrice_TBL", "Year=" & Me.Year)
      Else
    	Me.UpgradePrice = 0
      End If
    End Sub
    If you click in the word DLookup in the Visual Basic Editor and press F1, you'll get help about the DLookup function.

  3. #3
    Lounger
    Join Date
    May 2004
    Location
    Pardeeville, Wisconsin, USA
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post

    [quote name='HansV' post='775987' date='19-May-2009 16:52']I'm not sure I understand what you want, but can't refer to a table as Form!...
    Try this:

    Code:
    Private Sub UpgradePrice_GotFocus()
      If Me.UpgradeBusinessCard = True Then
    	Me.UpgradePrice = DLookup("UpgradePrice", "UpGradePrice_TBL", "Year=" & Me.Year)
      Else
    	Me.UpgradePrice = 0
      End If
    End Sub
    If you click in the word DLookup in the Visual Basic Editor and press F1, you'll get help about the DLookup function.[/quote]


    Thank you! This worked perfectly.

Posting Permissions

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