PC Review


Reply
Thread Tools Rating: Thread Rating: 1 votes, 1.00 average.

default to first item in combo box list

 
 
SuzyQ
Guest
Posts: n/a
 
      27th Apr 2009
How can I get access to use the first item in the list of a combo box on a
form if the field in question is currently null? I'm trying to speed up data
entry, and 99.9% of the time on this particular combo box, the first item in
the list is the item the user chooses. It would be nice if they could just
tab throug the field and it would populate rather than having to select from
the list. Then on the rare case where they select something other than the
first item on the list, they could select it.
 
Reply With Quote
 
 
 
 
fredg
Guest
Posts: n/a
 
      28th Apr 2009
On Mon, 27 Apr 2009 15:13:01 -0700, SuzyQ wrote:

> How can I get access to use the first item in the list of a combo box on a
> form if the field in question is currently null? I'm trying to speed up data
> entry, and 99.9% of the time on this particular combo box, the first item in
> the list is the item the user chooses. It would be nice if they could just
> tab throug the field and it would populate rather than having to select from
> the list. Then on the rare case where they select something other than the
> first item on the list, they could select it.


What is the Combo Row Source?
What is the first item in the list?
Is that first item always the same item?

Set the default value to whatever the value is of the bound column
first row.
For example, if the Rowsource returns CompanyID and CompanyName
fields, and the CompanyID of the Company you mostly use is 456, then
set the Combo default value property to 456.
Note: the default value can be anywhere in the list, not just the
first item.

The Default value only comes into usage on new records.
If you have something else as row source, then you need to give us
more information.


--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
 
Reply With Quote
 
Mr. B
Guest
Posts: n/a
 
      28th Apr 2009
SuzyQ,

If you want to assign the first value in your combo box to be the value of
the combo box for each new record add the following code to the OnCurrent
event of your form:

If Me.NewRecord Then
Me.NameOfComboBox= Me.NameOfComboBox.ItemData(0)
End If

Just change the "NameOfComboBox" to the actual name of your combo box.

-----
HTH
Mr. B
askdoctoraccess dot com


"SuzyQ" wrote:

> How can I get access to use the first item in the list of a combo box on a
> form if the field in question is currently null? I'm trying to speed up data
> entry, and 99.9% of the time on this particular combo box, the first item in
> the list is the item the user chooses. It would be nice if they could just
> tab throug the field and it would populate rather than having to select from
> the list. Then on the rare case where they select something other than the
> first item on the list, they could select it.

 
Reply With Quote
 
SuzyQ
Guest
Posts: n/a
 
      29th Apr 2009
> What is the Combo Row Source? it is a query = "SELECT
[tblJobLine].[LineNo], [tblLineNumbers].[Description], [tblJobLine].[JobCode]
FROM tblJobLine INNER JOIN tblLineNumbers ON
[tblJobLine].[LineNo]=[tblLineNumbers].[LineNo] WHERE
((([tblJobLine].[JobCode])=[forms].[frmTimeSheet].[txtJobCode] Or
([tblJobLine].[JobCode])=[forms].[frmTimeSheet].[txtAdminCode])) ORDER BY
[tblJobLine].[LineNo]; "

> What is the first item in the list? varies depending on the data in the JobCode field


> Is that first item always the same item? no


The default for the particular jobcode is always at the top of the query
data for the current record, however it is not the same for all job codes.
For instance if jobcode = "025" then lineno can be "25", "26", or "47" - "25"
is listed first
jobcode = "073" then lineno can be "44", or "47" - "44" is listed first
jobcode = "165" then lineno can be "37" or "47" - "37" is listed first

however until jobcode is entered the query just has a "47" record. Once the
job code is entered the lineno field requeries and the list is updated. As
you tab through the fields (lineno tab order is sometime after jobcodes tab
number so it is after lineno) rather than droping the list down to select (or
even as soon as JobCode has been updated) I want lineno to take the value of
the first item of the query for that field.

"fredg" wrote:

> On Mon, 27 Apr 2009 15:13:01 -0700, SuzyQ wrote:
>
> > How can I get access to use the first item in the list of a combo box on a
> > form if the field in question is currently null? I'm trying to speed up data
> > entry, and 99.9% of the time on this particular combo box, the first item in
> > the list is the item the user chooses. It would be nice if they could just
> > tab throug the field and it would populate rather than having to select from
> > the list. Then on the rare case where they select something other than the
> > first item on the list, they could select it.

>
> What is the Combo Row Source?
> What is the first item in the list?
> Is that first item always the same item?
>
> Set the default value to whatever the value is of the bound column
> first row.
> For example, if the Rowsource returns CompanyID and CompanyName
> fields, and the CompanyID of the Company you mostly use is 456, then
> set the Combo default value property to 456.
> Note: the default value can be anywhere in the list, not just the
> first item.
>
> The Default value only comes into usage on new records.
> If you have something else as row source, then you need to give us
> more information.
>
>
> --
> Fred
> Please respond only to this newsgroup.
> I do not reply to personal e-mail
>

 
Reply With Quote
 
SuzyQ
Guest
Posts: n/a
 
      30th Apr 2009
I did it this way (see response to fredg for reason), but the code you gave
was what I was looking for. Thanks

Private Sub JobCode_AfterUpdate()
[Forms]![frmTimeSheet]!txtJobCode = Me.JobCode
Me.LineNo.Requery
Me.LineNo = Me.LineNo.ItemData(0)
End Sub


"Mr. B" wrote:

> SuzyQ,
>
> If you want to assign the first value in your combo box to be the value of
> the combo box for each new record add the following code to the OnCurrent
> event of your form:
>
> If Me.NewRecord Then
> Me.NameOfComboBox= Me.NameOfComboBox.ItemData(0)
> End If
>
> Just change the "NameOfComboBox" to the actual name of your combo box.
>
> -----
> HTH
> Mr. B
> askdoctoraccess dot com
>
>
> "SuzyQ" wrote:
>
> > How can I get access to use the first item in the list of a combo box on a
> > form if the field in question is currently null? I'm trying to speed up data
> > entry, and 99.9% of the time on this particular combo box, the first item in
> > the list is the item the user chooses. It would be nice if they could just
> > tab throug the field and it would populate rather than having to select from
> > the list. Then on the rare case where they select something other than the
> > first item on the list, they could select it.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Combo box display first item in list CharlesD Microsoft Access Form Coding 4 15th Sep 2009 12:24 AM
Adding item to list for combo box sammy Microsoft Access Form Coding 9 14th May 2004 05:38 AM
combo box - select and highlight default item ? =?Utf-8?B?Y2FtZXJvbg==?= Microsoft Access Form Coding 1 14th Apr 2004 08:30 PM
<All> first item in combo box list Gary Schuldt Microsoft Access Forms 5 15th Feb 2004 08:32 AM
Set value of combo box to first item in list Newbie Microsoft Access Form Coding 10 21st Oct 2003 09:30 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:48 AM.