Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I set up the default value of a combo box? 3

Status
Not open for further replies.

Rmcta

Technical User
Nov 1, 2002
478
0
0
US
I have a combo box on a form with the following row source:
SELECT qryDate.AccessDate FROM qryDate;

I would like to set up its default value to Min(qryDate.AccessDate).

Can it be done? If yes, how?
I don't seem to be able to make it work.
Thank you
 
You can paste this code in a module.

Code:
Function Smalldate()
Dim strSQL As String
Dim db As DAO.Database
Dim rs As DAO.Recordset
    strSQL = "SELECT Min(qryDate.AccessDate) as DateX FROM qryDate;"
    Set db = CurrentDb()
    Set rs = db.OpenRecordset(strSQL)
        rs.MoveFirst
        Smalldate = rs!dateX
    Set db = Nothing
    Set rs = Nothing
End Function

Then in your combobox's default value property enter:
SmallDate()
You'll also need a reference to DAO 3.X.

HTH,
Eric
 
In the combo box default value property you may enter:
DMin("AccessDate", "qryDate")

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thank you all for your great help!
 
One more question:

I open the form and my default values are ok.
On the same form a user clicks a button to load new data.
Now my default values are no longer correct.
Is there a way to refresh the queries that populate the default value of my combo boxes?

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top