getting variable from query into form

  • Thread starter Globalnet_renato
  • 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
 
M

Marshall Barton

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 & """")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top