Double click on ComboBox

I

iwasinnihon

I really appreciate everyone's help. This board has been extremely
helpful. I have really learned a lot.

I have a form that has a list box that displays all the information in
a table. Under the list box are fields that you can enter in
information click a button and it will input the information in the
fields into the table and refresh the list box. What I want is to be
able to double click on an item in the list box and have it populate
the fields below with that information so that it can be updated. Then
be able to click a button and have it update the table and refresh the
box and clear the fields.
 
S

Steve Schapel

iwasinnihon,

First of all, it will help to clarify communication to remember that
forms do not have fields. Forms have controls, and tables and queries
have fields. Sorry, I don't mean the be pedantic, but we can easily get
confused when discussing such topics.

So, can you let us know whether the controls (textboxes etc) on the form
are bound to fields in a table? In other words, if you look at the
Properties of a textbox on the form, is there the name of a field
entered in the Control Source property? When you say "click a button
and it will input the information in the fields into the table", are you
able to say by what mechanism this occurs? Is there macro or code on
the button's Click event that runs an Append Query or some such? Just
trying to understand what you're working with there.

In any case, I would advise against using the Dbl Click event of a
listbox for such a purpose. Seems awkward. Possibly the After Update
evernt, but probably best to select the item you want in the listbox,
and then have another command button to find the associated record. But
how to do that will depend on your answers to the other questions about
bound/unbound etc. Thanks.
 
I

iwasinnihon

The controls are all bound to fields in a table. When you click on the
button it adds the information in the controls to the table. I didn't
write any code for it. I used the wizard to create the form.
 
S

Steve Schapel

iwasinnihon,

Ok, thanks. So what does clicking on the button actually do? If the
controls are bound, then clicking the button doesn't actually adds the
information in the controls to the table. I wouold guess it either
closes the form, or moves to a new record?

As for the listbox (the subject header of your message says combobox,
whereas in the description you say listbox, so I will take it to be a
listbox - is that right?), I gather that this is unbound (i.e. no
Control Source) - is that right? Can you look at the Properties of the
listbox, and let us know what it has for these properties:
Row Source
Column Count
Bound Column
Column Widths
 
I

iwasinnihon

The button refreshes the list box and clears the controls for a new
record.
Here are the properties that you wanted

Control Source is blank

Row Source
SELECT Software.SoftwareID, Software.Title, Software.Platform,
Software.Maker, Software.KeyCode, Software.TotalLicensesCount,
Software.Price, Software.[MediaCD/DVD], Software.PurchaseDate FROM
Software ORDER BY [Title];

Column Count
8

Bound Column
1

Column Widths
0";1";1";1";1";1";1";1";1"
 
S

Steve Schapel

iwasinnihon,

Ok, on the basis of the information I have so far, it seems to me that
you could put code similar to this on the Click event of a button, and
run it after selecting an item in the listbox...

Me.SoftwareID.SetFocus
DoCmd.FindRecord Me.NameOfListbox

(substitute actual name of listbox).

Let us know how you get on with this.

--
Steve Schapel, Microsoft Access MVP
The button refreshes the list box and clears the controls for a new
record.
Here are the properties that you wanted

Control Source is blank

Row Source
SELECT Software.SoftwareID, Software.Title, Software.Platform,
Software.Maker, Software.KeyCode, Software.TotalLicensesCount,
Software.Price, Software.[MediaCD/DVD], Software.PurchaseDate FROM
Software ORDER BY [Title];

Column Count
8

Bound Column
1

Column Widths
0";1";1";1";1";1";1";1";1"
 
I

iwasinnihon

When I try that I get the following error

You can't use Find or Replace now.


Steve said:
iwasinnihon,

Ok, on the basis of the information I have so far, it seems to me that
you could put code similar to this on the Click event of a button, and
run it after selecting an item in the listbox...

Me.SoftwareID.SetFocus
DoCmd.FindRecord Me.NameOfListbox

(substitute actual name of listbox).

Let us know how you get on with this.

--
Steve Schapel, Microsoft Access MVP
The button refreshes the list box and clears the controls for a new
record.
Here are the properties that you wanted

Control Source is blank

Row Source
SELECT Software.SoftwareID, Software.Title, Software.Platform,
Software.Maker, Software.KeyCode, Software.TotalLicensesCount,
Software.Price, Software.[MediaCD/DVD], Software.PurchaseDate FROM
Software ORDER BY [Title];

Column Count
8

Bound Column
1

Column Widths
0";1";1";1";1";1";1";1";1"


Steve said:
iwasinnihon,

Ok, thanks. So what does clicking on the button actually do? If the
controls are bound, then clicking the button doesn't actually adds the
information in the controls to the table. I wouold guess it either
closes the form, or moves to a new record?

As for the listbox (the subject header of your message says combobox,
whereas in the description you say listbox, so I will take it to be a
listbox - is that right?), I gather that this is unbound (i.e. no
Control Source) - is that right? Can you look at the Properties of the
listbox, and let us know what it has for these properties:
Row Source
Column Count
Bound Column
Column Widths

--
Steve Schapel, Microsoft Access MVP

iwasinnihon wrote:
The controls are all bound to fields in a table. When you click on the
button it adds the information in the controls to the table. I didn't
write any code for it. I used the wizard to create the form.
 
I

iwasinnihon

I figured out why I was receiving that error. I was bringing up that
form with a button on a menu with the following command.

DoCmd.OpenForm stDocName, , , acAdd

This brought it up in filtered mode. I was doing that because I want
the form to come up with the controls blank. Or in other words ready
to have the next record entered. Is there another way to do this?

When I try that I get the following error

You can't use Find or Replace now.


Steve said:
iwasinnihon,

Ok, on the basis of the information I have so far, it seems to me that
you could put code similar to this on the Click event of a button, and
run it after selecting an item in the listbox...

Me.SoftwareID.SetFocus
DoCmd.FindRecord Me.NameOfListbox

(substitute actual name of listbox).

Let us know how you get on with this.

--
Steve Schapel, Microsoft Access MVP
The button refreshes the list box and clears the controls for a new
record.
Here are the properties that you wanted

Control Source is blank

Row Source
SELECT Software.SoftwareID, Software.Title, Software.Platform,
Software.Maker, Software.KeyCode, Software.TotalLicensesCount,
Software.Price, Software.[MediaCD/DVD], Software.PurchaseDate FROM
Software ORDER BY [Title];

Column Count
8

Bound Column
1

Column Widths
0";1";1";1";1";1";1";1";1"


Steve Schapel wrote:
iwasinnihon,

Ok, thanks. So what does clicking on the button actually do? If the
controls are bound, then clicking the button doesn't actually adds the
information in the controls to the table. I wouold guess it either
closes the form, or moves to a new record?

As for the listbox (the subject header of your message says combobox,
whereas in the description you say listbox, so I will take it to be a
listbox - is that right?), I gather that this is unbound (i.e. no
Control Source) - is that right? Can you look at the Properties of the
listbox, and let us know what it has for these properties:
Row Source
Column Count
Bound Column
Column Widths

--
Steve Schapel, Microsoft Access MVP

iwasinnihon wrote:
The controls are all bound to fields in a table. When you click on the
button it adds the information in the controls to the table. I didn't
write any code for it. I used the wizard to create the form.
 
S

Steve Schapel

iwasinnihon,

I think there are basically two approaches you could take here.

First is, instead of your initial use of the acAdd argument, do it like
this instead...
DoCmd.OpenForm stDocName
DoCmd.GoToRecord , , acNewRec

Alternatively, I *think* (didn't test) you could add a line like this
ahead of the FindRecord code I suggested before...
Me.DataEntry = False
 

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

Top