Code draws info from Table to be placed into form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am sort of a newbie when it comes to writing code. (So please simple English)

I am working on a form using checkboxes which will assign an amount into a
separate field.
Example:

Private Sub Ctl1_2weekIntro_AfterUpdate()
If Me![1-2weekIntro] = True Then
Me![1-2weekIntro$] = "$35.00"
Else
Me![1-2weekIntro$] = Null
End If

End Sub

What I would like it to do is have the code draw from another table called
[PayTable] Referencing the field [PayID] “1“ then placing the value=($35.00)
which is being drawn from the field called [Amount] into
Me![1-2weekIntro$] = "$35.00"

I hope this makes since.
 
Adam said:
I am working on a form using checkboxes which will assign an amount into a
separate field.
Example:

Private Sub Ctl1_2weekIntro_AfterUpdate()
If Me![1-2weekIntro] = True Then
Me![1-2weekIntro$] = "$35.00"
Else
Me![1-2weekIntro$] = Null
End If

End Sub

What I would like it to do is have the code draw from another table called
[PayTable] Referencing the field [PayID] “1“ then placing the value=($35.00)
which is being drawn from the field called [Amount] into
Me![1-2weekIntro$] = "$35.00"


Be careful, it appears that you are using _ and -
inconsistently and the name of the check box is different in
the Sub and If statements.

You can use the DLookup function to retrieve the value from
PayTable. I think(?) the code would be like:

Private Sub Ctl1_2weekIntro_AfterUpdate()
If Me![Ctl1_2weekIntro] = True Then
Me![1-2weekIntro$] = DLookup("Amount", "PayTable", _
"PayID = 1")
Else
Me![1-2weekIntro$] = Null
End If
End Sub
 
Back
Top