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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combo Box Default Value

Status
Not open for further replies.

splint1906

Technical User
Jul 19, 2004
27
US
I asked a similar question earlier but now I'd like to explore some more functionality.

I have 2 combo boxes on my form where the user selects the Starting_Period and the Ending_Period. I'd like for the Ending_Period to default to the last entry in my tblPeriod (I maunally add to my tblPeriod after each monthly update of the database). The tblPeriod has an ID field & a Period field (MMM-YYYY).
For example, right now my tblPeriod has the following records:
ID Period
1 Jan-2004
2 Feb-2004
3 Mar-2004
4 Apr-2004
5 May-2004
6 Jun-2004
7 Jul-2004
8 Aug-2004

When the form opens I'd like for the Ending_Period field to default to Aug-2004.

Any suggestions?
 
Hi splint1906

If your latest date always has the highest ID number in the table, you can just set your combo's default value property to =DMax("[ID]","tblPeriod").

If not, we need to be a bit more clever.

Hope this helps.

Mac
 
How about...

Dim db as dao.database
dim rs as dao.recordset
set db = currentdb
set rs = db.openrecordset("tblPeriod")
rs.movelast
txtEndingPeriod = rs!EndingPeriod
set rs = nothing
set db = nothing


Randy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top