combo box - default value from query ?

  • Thread starter יריב החביב
  • Start date
×

יריב החביב

Hello,

We have 'combo box' that we want it to show,

as default, the date from query (wich show one (max) date).

I had try to write the path to the query in the properties

(default value) of the 'combo box' but it dont work (#error, name?)

Can you tell me how to do it.
 
G

gilbert alpough

יריב החביב said:
Hello,

We have 'combo box' that we want it to show,

as default, the date from query (wich show one (max) date).

I had try to write the path to the query in the properties

(default value) of the 'combo box' but it dont work (#error, name?)

Can you tell me how to do it.
 
K

Ken Sheridan

If the query returns just one row the you can use the DLookup function to get
the value from the field. Rather than using the combo box's properties sheet
put code in the form's Open event procedure to set the value of the property,
e.g.

Me.YourComboBox.DefaultValue = _
"""" & DLookup("YourField", "YourQuery") & """"

If the query returns more than one row and you want the Max value use the
DMax function:

Me.YourComboBox.DefaultValue = _
"""" & DMax("YourField", "YourQuery") & """"

The DefaultValue property is always a string expression, regardless of the
data type of the field in question, so should be wrapped in quotes characters
as above. Often this isn't absolutely necessary, but with dates it is
important, as a date in short date format will otherwise be interpreted as an
arithmetical expression and give the wrong result.

Ken Sheridan
Stafford, England
 

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

Similar Threads


Top