Re: Pre-position a combo box
- From: Paul <Paul@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 16 Feb 2007 19:44:03 -0800
Yep, sometimes there are things that seem so trivial and easy to the user
where it takes them a second or two to complete may actually take the
programmer a hundred (or more) lines of code just to accomplish the task and
ease usability concerns. I'm finding that having a library of snippets of
code of various tasks can make things a whole lot easier. Thanks.
"Bill" wrote:
Hi Paul,.
Would you believe that I was about to post that the
only way I could see to utilize the DefaultValue
property would be to first open a DAO Recordset
and locate the newly added record to determine
it's index position. BUT, that I was having a hard
time believing that it required all that effort for what
would seem like a small matter......OH WELL!
Thanks,
Bill
"Paul" <Paul@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:5A47962F-4E12-4661-8DF9-79B7E4D6B0D9@xxxxxxxxxxxxxxxx
Hello Bill,
You'll have to query the table by the new record's name. Try this in the
Northwind sample db:
Private Sub Command0_Click()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSQl As String
strSQl = "SELECT CustomerID, CompanyName " & _
"FROM Customers " & _
"WHERE CompanyName = ' " & Me.Text1 & " ';"
Set db = CurrentDb()
Set rs = db.OpenRecordset(strSQl, dbOpenSnapshot)
With rs
rs.MoveFirst
' Prints to immediate window to debug.
Debug.Print .Fields(0) & vbTab & _
.Fields(1) & vbTab
Me.Combo3.DefaultValue = " ' " & .Fields(0) & " ' "
.MoveNext
End With
Set db = Nothing
Set rs = Nothing
End Sub
Hope this helps.
Regards,
Paul
"Bill" wrote:
Default Value won't help me if I don't know the
index of the newly added record.....or am I
missing something here?
Bill
"Paul" <Paul@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:CD306C9D-B202-40A8-87DC-67F96268CC21@xxxxxxxxxxxxxxxx
Hello Bill,
Take a look at the control's default value property in the help file.
That
should help.
Regards,
Paul
"Bill" wrote:
How does one pre-position a select in
a combo box?
I've just added a new record to the Rowsource
and have Required the combo and want to have
the newly added record pre-selected following
the Requery.
I would necessarily have to find the item based
on its display name, as I don't yet have its newly
assigned autonumber.
Thanks,
Bill
- References:
- Pre-position a combo box
- From: Bill
- Re: Pre-position a combo box
- From: Bill
- Re: Pre-position a combo box
- From: Paul
- Re: Pre-position a combo box
- From: Bill
- Pre-position a combo box
- Prev by Date: Re: Pre-position a combo box
- Next by Date: RE: "dummies guide" to opening subform with new record using a val
- Previous by thread: Re: Pre-position a combo box
- Next by thread: Re: Shell external application and wait
- Index(es):
Relevant Pages
|