getting variable from query into form

  • Thread starter Thread starter Globalnet_renato
  • Start date Start date
G

Globalnet_renato

i am having a form with combo1 and textfield1.when i get event on
combo1(lostfocus-event) i must create a code that should query some table
based on selection in combo1 and then insert some result in textfield1.

example

when i lostfocus

query:select something from somewhere where something=combo1

then i should be able to get the desired field from that query as a variable
and do some math and insert the result into textfield1

thx


rene
 
Globalnet_renato said:
i am having a form with combo1 and textfield1.when i get event on
combo1(lostfocus-event) i must create a code that should query some table
based on selection in combo1 and then insert some result in textfield1.

example

when i lostfocus

query:select something from somewhere where something=combo1

then i should be able to get the desired field from that query as a variable
and do some math and insert the result into textfield1


You can use the DLookup function for this. If something is
a numeric field:

varX = DLookup("somefield", "sometable", _
"something=" & combo1)

If it's a Text field:

varX = DLookup("somefield", "sometable", _
"something=""" & combo1 & """")
 
Back
Top