Update a listbox in a tab on a form

  • Thread starter BTU_needs_assistance_43
  • Start date
B

BTU_needs_assistance_43

I have a list box which is defined by a number in a textbox on any given
record. If I open the query which the list draws its information from and
close it, the record will display the data tied to the record. But if I move
to another record or don't open the query the list box will remain blank or
keep the same data on its table until I open and close the source query
again. Is there a command I should write into the event procedure? On update?
On click? How do I make this list box display the data on its own when I open
the form and switch data when I move to a new record?
 
J

JimBurke via AccessMonster.com

Assuming that each time you move to a new record that query will have what it
needs to populate the listbox, you should just set the listbox's row source
type to Table/Query and set the rowsource to the name of the query that is
used to populate it. Without knowing what the query does it's hard to say for
sure that this will work. But if the query just selects data based on the
numeric value from the textbox, that should work. I guess it's possible that
you would need to do a requery on the listbox in the form's On Current event,
e.g. lstBoxname.Requery, but its seems like that shouldn't be needed as long
as you have the RowSource set. On Current gets triggererd when you move to a
new record.
 
B

BTU_needs_assistance_43

I'm using Access 2003 and it does not have the On Current event except in the
expression builder. I've tried using On Current there too and it doesn't
work. The only ones that seem to work are when I paste your code
[MyLstBox].[Requery] in the OnClick Event. That will do if I can't make
anything else work, but I'd really just like it to do it when I click on the
next record button on the bottom or type in a specific record number. I
suppose that would probably take a little time for me to sit down an write
some code in VBA?
 
J

JimBurke via AccessMonster.com

On Current is a form event. It shouldn't matter what version you're using.
Bring up the form's properties and you should see On Current on the events
tab.

BTU_needs_assistance_43 said:
I'm using Access 2003 and it does not have the On Current event except in the
expression builder. I've tried using On Current there too and it doesn't
work. The only ones that seem to work are when I paste your code
[MyLstBox].[Requery] in the OnClick Event. That will do if I can't make
anything else work, but I'd really just like it to do it when I click on the
next record button on the bottom or type in a specific record number. I
suppose that would probably take a little time for me to sit down an write
some code in VBA?
Assuming that each time you move to a new record that query will have what it
needs to populate the listbox, you should just set the listbox's row source
[quoted text clipped - 15 lines]
 
B

BTU_needs_assistance_43

I open the form, go to design mode, right click, select properties, click on
the event tab right after data and right before other, and these are the
options available;

Before Update
After Update
On Enter
On Exit
On Got Focus
On Lost Focus
On Click
On Dbl Click
On Mouse Down
On Mouse Move
On Mouse Up
On Key Down
On Key Up
On Key Press

Thats it. Even if I start a new database and build a new form and listbox
there is no On Current option on the events tab.

JimBurke via AccessMonster.com said:
On Current is a form event. It shouldn't matter what version you're using.
Bring up the form's properties and you should see On Current on the events
tab.

BTU_needs_assistance_43 said:
I'm using Access 2003 and it does not have the On Current event except in the
expression builder. I've tried using On Current there too and it doesn't
work. The only ones that seem to work are when I paste your code
[MyLstBox].[Requery] in the OnClick Event. That will do if I can't make
anything else work, but I'd really just like it to do it when I click on the
next record button on the bottom or type in a specific record number. I
suppose that would probably take a little time for me to sit down an write
some code in VBA?
Assuming that each time you move to a new record that query will have what it
needs to populate the listbox, you should just set the listbox's row source
[quoted text clipped - 15 lines]
On click? How do I make this list box display the data on its own when I open
the form and switch data when I move to a new record?
 
J

JimBurke via AccessMonster.com

You are sure you're looking at the form's properties? That looks to be the
properties of a text box or combo box or some othe form control to me. A form
should have a lot more events than that. When you have the proprties
displayed what does it say at the top of the list? It should say 'Form'. All
forms should have an On Current Event as far as I know. maybe someone else
can explain this.

BTU_needs_assistance_43 said:
I open the form, go to design mode, right click, select properties, click on
the event tab right after data and right before other, and these are the
options available;

Before Update
After Update
On Enter
On Exit
On Got Focus
On Lost Focus
On Click
On Dbl Click
On Mouse Down
On Mouse Move
On Mouse Up
On Key Down
On Key Up
On Key Press

Thats it. Even if I start a new database and build a new form and listbox
there is no On Current option on the events tab.
On Current is a form event. It shouldn't matter what version you're using.
Bring up the form's properties and you should see On Current on the events
[quoted text clipped - 14 lines]
 
J

JimBurke via AccessMonster.com

I was assuming you knew this but maybe not. To look at the form properties
you have to click in the little box in the upper left hand corner, just to
the left of the 'ruler' and above the form header (or detail section if you
don't have the header displayed).

BTU_needs_assistance_43 said:
I open the form, go to design mode, right click, select properties, click on
the event tab right after data and right before other, and these are the
options available;

Before Update
After Update
On Enter
On Exit
On Got Focus
On Lost Focus
On Click
On Dbl Click
On Mouse Down
On Mouse Move
On Mouse Up
On Key Down
On Key Up
On Key Press

Thats it. Even if I start a new database and build a new form and listbox
there is no On Current option on the events tab.
On Current is a form event. It shouldn't matter what version you're using.
Bring up the form's properties and you should see On Current on the events
[quoted text clipped - 14 lines]
 
J

JimBurke via AccessMonster.com

Whoops, clicked Post too fast. Either right click on that box and select
properties from the list or else left click, then do View, Properties.
I was assuming you knew this but maybe not. To look at the form properties
you have to click in the little box in the upper left hand corner, just to
the left of the 'ruler' and above the form header (or detail section if you
don't have the header displayed).
I open the form, go to design mode, right click, select properties, click on
the event tab right after data and right before other, and these are the
[quoted text clipped - 23 lines]
 
B

BTU_needs_assistance_43

You got it. I wasn't looking at the form properties, just the list box's. And
it works just the way I want it to now. Thank you very much.

JimBurke via AccessMonster.com said:
I was assuming you knew this but maybe not. To look at the form properties
you have to click in the little box in the upper left hand corner, just to
the left of the 'ruler' and above the form header (or detail section if you
don't have the header displayed).

BTU_needs_assistance_43 said:
I open the form, go to design mode, right click, select properties, click on
the event tab right after data and right before other, and these are the
options available;

Before Update
After Update
On Enter
On Exit
On Got Focus
On Lost Focus
On Click
On Dbl Click
On Mouse Down
On Mouse Move
On Mouse Up
On Key Down
On Key Up
On Key Press

Thats it. Even if I start a new database and build a new form and listbox
there is no On Current option on the events tab.
On Current is a form event. It shouldn't matter what version you're using.
Bring up the form's properties and you should see On Current on the events
[quoted text clipped - 14 lines]
On click? How do I make this list box display the data on its own when I open
the form and switch data when I move to a new record?
 

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