onCurrent form box, updating combo ?

  • Thread starter Thread starter steve
  • Start date Start date
S

steve

I'm going to try to re-phrase my initial question as I didn't unfortunately
resolve my problem:


I have a form which is bound to a table: client

Within the form, I have a text box called: Townbox

When I enter the form it can be either already populated with a Town name or
entered manually.

I require that the individual entry which appears in each Townbox record
[when it's visible or entered] to update the combo box [which follow's] list
from a different table: companies - which itself should display the Firm
names and Town [just to confirm] which matches the Town in my client table.


I was reading somewhere that an onCurrent event proceedure for the form's
Townbox combined with an SQL query in the combo box may be the answer, but
am new to Even Procedures and would appreciate any expert advise.

Thanks again,


Steve.
 
The OnCurrent event is triggered everytime a different record is shown on
the form. This inlcudes the first record that is shown when the form first
opens, each time you move to another record by using the navigation buttons
(or custom buttons), or you get to the new record. This will be where you
would put code if you wanted to change something based on a value on a form
that changes for each record, like the town in your case. To update the
combo box based on the value in Townbox you need to do 2 things. First, you
need to modify the query for the combobox to include a criteria where the
town (the field in the query) is equal to Forms!NameOfForm!Townbox. Then
add code in the OnCurrent event of the form. Me!NameOfComboBox.Requery.
This will force the contents of the combobox to update for each record.

For situations where there is not an entry already in Townbox, the combobox
will be blank since the query from above will not find a match and return
nothing. Since the query for the combo box is still using the value in
Townbox you do not need to change the query. After the user enters
something into Townbox then you want the combobox to get updated again, so
add Me!NameOfcomboBox.Requery into the code for the AfterUpdate of Townbox.
The AfterUpdate event is triggered everytime the user manually changes the
contents of that box. So if the user changes a value that is already in the
box, this event will be triggered.

Kelvin
 
Thanks Kelvin, I'll give it a try and report back.


Steve.


Kelvin said:
The OnCurrent event is triggered everytime a different record is shown on
the form. This inlcudes the first record that is shown when the form first
opens, each time you move to another record by using the navigation buttons
(or custom buttons), or you get to the new record. This will be where you
would put code if you wanted to change something based on a value on a form
that changes for each record, like the town in your case. To update the
combo box based on the value in Townbox you need to do 2 things. First, you
need to modify the query for the combobox to include a criteria where the
town (the field in the query) is equal to Forms!NameOfForm!Townbox. Then
add code in the OnCurrent event of the form. Me!NameOfComboBox.Requery.
This will force the contents of the combobox to update for each record.

For situations where there is not an entry already in Townbox, the combobox
will be blank since the query from above will not find a match and return
nothing. Since the query for the combo box is still using the value in
Townbox you do not need to change the query. After the user enters
something into Townbox then you want the combobox to get updated again, so
add Me!NameOfcomboBox.Requery into the code for the AfterUpdate of Townbox.
The AfterUpdate event is triggered everytime the user manually changes the
contents of that box. So if the user changes a value that is already in the
box, this event will be triggered.

Kelvin

steve said:
I'm going to try to re-phrase my initial question as I didn't unfortunately
resolve my problem:


I have a form which is bound to a table: client

Within the form, I have a text box called: Townbox

When I enter the form it can be either already populated with a Town
name
or
entered manually.

I require that the individual entry which appears in each Townbox record
[when it's visible or entered] to update the combo box [which follow's] list
from a different table: companies - which itself should display the Firm
names and Town [just to confirm] which matches the Town in my client table.


I was reading somewhere that an onCurrent event proceedure for the form's
Townbox combined with an SQL query in the combo box may be the answer, but
am new to Even Procedures and would appreciate any expert advise.

Thanks again,


Steve.
 
Back
Top