Combo Box text display problem based on AfterUpdate...

G

Guest

I have three tables defined at follows:

tblStore:
Primary Key: lngStoreID AutoNumber
strStoreName Text

tblManager:
Primary Key: lngManagerID AutoNumber
lngStoreID Number
strManagerName Text

tblEmployee:
Primary Key: lngEmployeeID AutoNumber
lngManagerID Number
strEmployeeName Text

I have 3 combo boxes, cboStore, cboManager, and cboEmployee

The AfterUpdate for cboStore is as follows and and the store picked is used
to filter the managers name that will display in cboManager

Private Sub cboStore_AfterUpdate()
Dim sManagerSource As String

sManagerSource = "SELECT [tblManager].[lngManagerID],
[tblManager].[lngStoreID], [tblManager].[strManagerName] " & _
"FROM tblManager " & _
"WHERE [lngStoreID] = " & Me.cboStore.Value
Me.cboManager.RowSource = sManagerSource
Me.cboManager.Requery
End Sub

The AfterUpdate for cboManager is as follows and the manager name picked is
used to filter the employee name that will display in cboEmployee

Private Sub cboManager_AfterUpdate()
Dim sEmployeeSource As String

sEmployeeSource = "SELECT
[tblEmployee].[lngEmployeeID],[tblEmployee].[lngManagerID],
[tblEmployee].[strEmployeeName] " & _
"FROM tblEmployee " & _
"WHERE [lngManagerID] = " & Me.cboManager.Value
Me.cboEmployee.RowSource = sEmployeeSource
Me.cboEmployee.Requery
End Sub

The cboStore displays the strStoreName (Text), the cboManger displays the
strManagerName (Text) based on the store picked, but the cboEmployee displays
the lngMangaerID (Number) instead of the strEmployeeName (Text)…. What’s
wrong??? Thanks….Joe…
 
K

Ken Snell \(MVP\)

Sounds like the column widths property is not properly set. It should be
this:

0";0";1"

Or use whatever width for the third colum that you want. Also be sure that
the column count property is set to 3.
 
G

Guest

Thanks! but how did you know???

Ken Snell (MVP) said:
Sounds like the column widths property is not properly set. It should be
this:

0";0";1"

Or use whatever width for the third colum that you want. Also be sure that
the column count property is set to 3.

--

Ken Snell
<MS ACCESS MVP>

Joe Leon said:
I have three tables defined at follows:

tblStore:
Primary Key: lngStoreID AutoNumber
strStoreName Text

tblManager:
Primary Key: lngManagerID AutoNumber
lngStoreID Number
strManagerName Text

tblEmployee:
Primary Key: lngEmployeeID AutoNumber
lngManagerID Number
strEmployeeName Text

I have 3 combo boxes, cboStore, cboManager, and cboEmployee

The AfterUpdate for cboStore is as follows and and the store picked is
used
to filter the managers name that will display in cboManager

Private Sub cboStore_AfterUpdate()
Dim sManagerSource As String

sManagerSource = "SELECT [tblManager].[lngManagerID],
[tblManager].[lngStoreID], [tblManager].[strManagerName] " & _
"FROM tblManager " & _
"WHERE [lngStoreID] = " & Me.cboStore.Value
Me.cboManager.RowSource = sManagerSource
Me.cboManager.Requery
End Sub

The AfterUpdate for cboManager is as follows and the manager name picked
is
used to filter the employee name that will display in cboEmployee

Private Sub cboManager_AfterUpdate()
Dim sEmployeeSource As String

sEmployeeSource = "SELECT
[tblEmployee].[lngEmployeeID],[tblEmployee].[lngManagerID],
[tblEmployee].[strEmployeeName] " & _
"FROM tblEmployee " & _
"WHERE [lngManagerID] = " & Me.cboManager.Value
Me.cboEmployee.RowSource = sEmployeeSource
Me.cboEmployee.Requery
End Sub

The cboStore displays the strStoreName (Text), the cboManger displays the
strManagerName (Text) based on the store picked, but the cboEmployee
displays
the lngMangaerID (Number) instead of the strEmployeeName (Text).. What's
wrong??? Thanks..Joe.
 
K

Ken Snell \(MVP\)

First clue was your statement that the cboEmployee combo box is showing the
lngMangaerID, which is the second column in the Row Source query.

Second clue was assuming that you probably copied the cboManager combo box
to make the cboEmployee combo box, and the cboManager combo box has only two
columns in its RowSource query. Common error to forget to change the
settings when doing this -- I've done it many times.

--

Ken Snell
<MS ACCESS MVP>


Joe Leon said:
Thanks! but how did you know???

Ken Snell (MVP) said:
Sounds like the column widths property is not properly set. It should be
this:

0";0";1"

Or use whatever width for the third colum that you want. Also be sure
that
the column count property is set to 3.

--

Ken Snell
<MS ACCESS MVP>

Joe Leon said:
I have three tables defined at follows:

tblStore:
Primary Key: lngStoreID AutoNumber
strStoreName Text

tblManager:
Primary Key: lngManagerID AutoNumber
lngStoreID Number
strManagerName Text

tblEmployee:
Primary Key: lngEmployeeID AutoNumber
lngManagerID Number
strEmployeeName Text

I have 3 combo boxes, cboStore, cboManager, and cboEmployee

The AfterUpdate for cboStore is as follows and and the store picked is
used
to filter the managers name that will display in cboManager

Private Sub cboStore_AfterUpdate()
Dim sManagerSource As String

sManagerSource = "SELECT [tblManager].[lngManagerID],
[tblManager].[lngStoreID], [tblManager].[strManagerName] " & _
"FROM tblManager " & _
"WHERE [lngStoreID] = " & Me.cboStore.Value
Me.cboManager.RowSource = sManagerSource
Me.cboManager.Requery
End Sub

The AfterUpdate for cboManager is as follows and the manager name
picked
is
used to filter the employee name that will display in cboEmployee

Private Sub cboManager_AfterUpdate()
Dim sEmployeeSource As String

sEmployeeSource = "SELECT
[tblEmployee].[lngEmployeeID],[tblEmployee].[lngManagerID],
[tblEmployee].[strEmployeeName] " & _
"FROM tblEmployee " & _
"WHERE [lngManagerID] = " & Me.cboManager.Value
Me.cboEmployee.RowSource = sEmployeeSource
Me.cboEmployee.Requery
End Sub

The cboStore displays the strStoreName (Text), the cboManger displays
the
strManagerName (Text) based on the store picked, but the cboEmployee
displays
the lngMangaerID (Number) instead of the strEmployeeName (Text)..
What's
wrong??? Thanks..Joe.
 
K

Ken Snell \(MVP\)

OK - second clue should say the first combo box not the second... but still
lets me appear to be clairvoyant < g >
--

Ken Snell
<MS ACCESS MVP>



Ken Snell (MVP) said:
First clue was your statement that the cboEmployee combo box is showing
the lngMangaerID, which is the second column in the Row Source query.

Second clue was assuming that you probably copied the cboManager combo box
to make the cboEmployee combo box, and the cboManager combo box has only
two columns in its RowSource query. Common error to forget to change the
settings when doing this -- I've done it many times.

--

Ken Snell
<MS ACCESS MVP>


Joe Leon said:
Thanks! but how did you know???

Ken Snell (MVP) said:
Sounds like the column widths property is not properly set. It should be
this:

0";0";1"

Or use whatever width for the third colum that you want. Also be sure
that
the column count property is set to 3.

--

Ken Snell
<MS ACCESS MVP>

I have three tables defined at follows:

tblStore:
Primary Key: lngStoreID AutoNumber
strStoreName Text

tblManager:
Primary Key: lngManagerID AutoNumber
lngStoreID Number
strManagerName Text

tblEmployee:
Primary Key: lngEmployeeID AutoNumber
lngManagerID Number
strEmployeeName Text

I have 3 combo boxes, cboStore, cboManager, and cboEmployee

The AfterUpdate for cboStore is as follows and and the store picked
is
used
to filter the managers name that will display in cboManager

Private Sub cboStore_AfterUpdate()
Dim sManagerSource As String

sManagerSource = "SELECT [tblManager].[lngManagerID],
[tblManager].[lngStoreID], [tblManager].[strManagerName] " & _
"FROM tblManager " & _
"WHERE [lngStoreID] = " & Me.cboStore.Value
Me.cboManager.RowSource = sManagerSource
Me.cboManager.Requery
End Sub

The AfterUpdate for cboManager is as follows and the manager name
picked
is
used to filter the employee name that will display in cboEmployee

Private Sub cboManager_AfterUpdate()
Dim sEmployeeSource As String

sEmployeeSource = "SELECT
[tblEmployee].[lngEmployeeID],[tblEmployee].[lngManagerID],
[tblEmployee].[strEmployeeName] " & _
"FROM tblEmployee " & _
"WHERE [lngManagerID] = " & Me.cboManager.Value
Me.cboEmployee.RowSource = sEmployeeSource
Me.cboEmployee.Requery
End Sub

The cboStore displays the strStoreName (Text), the cboManger displays
the
strManagerName (Text) based on the store picked, but the cboEmployee
displays
the lngMangaerID (Number) instead of the strEmployeeName (Text)..
What's
wrong??? Thanks..Joe.
 
G

Guest

Here's a follow on question.... Now that I have this working I tried placing
the StoreName, ManagerName, and EmployeeName in a table after the combo box
selction. But what I am storing is not the text but the ID. What am I doing
wrong?
Thanks...Joe...

Ken Snell (MVP) said:
OK - second clue should say the first combo box not the second... but still
lets me appear to be clairvoyant < g >
--

Ken Snell
<MS ACCESS MVP>



Ken Snell (MVP) said:
First clue was your statement that the cboEmployee combo box is showing
the lngMangaerID, which is the second column in the Row Source query.

Second clue was assuming that you probably copied the cboManager combo box
to make the cboEmployee combo box, and the cboManager combo box has only
two columns in its RowSource query. Common error to forget to change the
settings when doing this -- I've done it many times.

--

Ken Snell
<MS ACCESS MVP>


Joe Leon said:
Thanks! but how did you know???

:

Sounds like the column widths property is not properly set. It should be
this:

0";0";1"

Or use whatever width for the third colum that you want. Also be sure
that
the column count property is set to 3.

--

Ken Snell
<MS ACCESS MVP>

I have three tables defined at follows:

tblStore:
Primary Key: lngStoreID AutoNumber
strStoreName Text

tblManager:
Primary Key: lngManagerID AutoNumber
lngStoreID Number
strManagerName Text

tblEmployee:
Primary Key: lngEmployeeID AutoNumber
lngManagerID Number
strEmployeeName Text

I have 3 combo boxes, cboStore, cboManager, and cboEmployee

The AfterUpdate for cboStore is as follows and and the store picked
is
used
to filter the managers name that will display in cboManager

Private Sub cboStore_AfterUpdate()
Dim sManagerSource As String

sManagerSource = "SELECT [tblManager].[lngManagerID],
[tblManager].[lngStoreID], [tblManager].[strManagerName] " & _
"FROM tblManager " & _
"WHERE [lngStoreID] = " & Me.cboStore.Value
Me.cboManager.RowSource = sManagerSource
Me.cboManager.Requery
End Sub

The AfterUpdate for cboManager is as follows and the manager name
picked
is
used to filter the employee name that will display in cboEmployee

Private Sub cboManager_AfterUpdate()
Dim sEmployeeSource As String

sEmployeeSource = "SELECT
[tblEmployee].[lngEmployeeID],[tblEmployee].[lngManagerID],
[tblEmployee].[strEmployeeName] " & _
"FROM tblEmployee " & _
"WHERE [lngManagerID] = " & Me.cboManager.Value
Me.cboEmployee.RowSource = sEmployeeSource
Me.cboEmployee.Requery
End Sub

The cboStore displays the strStoreName (Text), the cboManger displays
the
strManagerName (Text) based on the store picked, but the cboEmployee
displays
the lngMangaerID (Number) instead of the strEmployeeName (Text)..
What's
wrong??? Thanks..Joe.
 
K

Ken Snell \(MVP\)

You should be storing the ID, not the name. The bound column of the combo
box is the column whose value is actually the value of the combo box. In a
relational database, you store the related field value, and then you use a
query to get the actual name when you want it for another form or report.

This means that you can update a store name in the store table, and not need
to update it in all the other records where you'd stored a name instead of
the StoreID.

So your setup is working correctly.
--

Ken Snell
<MS ACCESS MVP>




Joe Leon said:
Here's a follow on question.... Now that I have this working I tried
placing
the StoreName, ManagerName, and EmployeeName in a table after the combo
box
selction. But what I am storing is not the text but the ID. What am I
doing
wrong?
Thanks...Joe...

Ken Snell (MVP) said:
OK - second clue should say the first combo box not the second... but
still
lets me appear to be clairvoyant < g >
--

Ken Snell
<MS ACCESS MVP>



Ken Snell (MVP) said:
First clue was your statement that the cboEmployee combo box is showing
the lngMangaerID, which is the second column in the Row Source query.

Second clue was assuming that you probably copied the cboManager combo
box
to make the cboEmployee combo box, and the cboManager combo box has
only
two columns in its RowSource query. Common error to forget to change
the
settings when doing this -- I've done it many times.

--

Ken Snell
<MS ACCESS MVP>


Thanks! but how did you know???

:

Sounds like the column widths property is not properly set. It should
be
this:

0";0";1"

Or use whatever width for the third colum that you want. Also be sure
that
the column count property is set to 3.

--

Ken Snell
<MS ACCESS MVP>

I have three tables defined at follows:

tblStore:
Primary Key: lngStoreID AutoNumber
strStoreName Text

tblManager:
Primary Key: lngManagerID AutoNumber
lngStoreID Number
strManagerName Text

tblEmployee:
Primary Key: lngEmployeeID AutoNumber
lngManagerID Number
strEmployeeName Text

I have 3 combo boxes, cboStore, cboManager, and cboEmployee

The AfterUpdate for cboStore is as follows and and the store picked
is
used
to filter the managers name that will display in cboManager

Private Sub cboStore_AfterUpdate()
Dim sManagerSource As String

sManagerSource = "SELECT [tblManager].[lngManagerID],
[tblManager].[lngStoreID], [tblManager].[strManagerName] " & _
"FROM tblManager " & _
"WHERE [lngStoreID] = " & Me.cboStore.Value
Me.cboManager.RowSource = sManagerSource
Me.cboManager.Requery
End Sub

The AfterUpdate for cboManager is as follows and the manager name
picked
is
used to filter the employee name that will display in cboEmployee

Private Sub cboManager_AfterUpdate()
Dim sEmployeeSource As String

sEmployeeSource = "SELECT
[tblEmployee].[lngEmployeeID],[tblEmployee].[lngManagerID],
[tblEmployee].[strEmployeeName] " & _
"FROM tblEmployee " & _
"WHERE [lngManagerID] = " &
Me.cboManager.Value
Me.cboEmployee.RowSource = sEmployeeSource
Me.cboEmployee.Requery
End Sub

The cboStore displays the strStoreName (Text), the cboManger
displays
the
strManagerName (Text) based on the store picked, but the
cboEmployee
displays
the lngMangaerID (Number) instead of the strEmployeeName (Text)..
What's
wrong??? Thanks..Joe.
 
G

Guest

Thanks...

But I'm having a problem coming up with the query.

So far, from the form I created, the table is getting filled with the
following 4 records:

tblPickID | Store | Manager | Employee
1 | 1 | 1 | 2
2 | 2 | 4 | 9
3 | 3 | 6 | 18
4 | 4 | 8 | 16

And yes you're right all the values match as you say. But I'm having
problems coming up with the query. Thanks... Joe...



Ken Snell (MVP) said:
You should be storing the ID, not the name. The bound column of the combo
box is the column whose value is actually the value of the combo box. In a
relational database, you store the related field value, and then you use a
query to get the actual name when you want it for another form or report.

This means that you can update a store name in the store table, and not need
to update it in all the other records where you'd stored a name instead of
the StoreID.

So your setup is working correctly.
--

Ken Snell
<MS ACCESS MVP>




Joe Leon said:
Here's a follow on question.... Now that I have this working I tried
placing
the StoreName, ManagerName, and EmployeeName in a table after the combo
box
selction. But what I am storing is not the text but the ID. What am I
doing
wrong?
Thanks...Joe...

Ken Snell (MVP) said:
OK - second clue should say the first combo box not the second... but
still
lets me appear to be clairvoyant < g >
--

Ken Snell
<MS ACCESS MVP>



First clue was your statement that the cboEmployee combo box is showing
the lngMangaerID, which is the second column in the Row Source query.

Second clue was assuming that you probably copied the cboManager combo
box
to make the cboEmployee combo box, and the cboManager combo box has
only
two columns in its RowSource query. Common error to forget to change
the
settings when doing this -- I've done it many times.

--

Ken Snell
<MS ACCESS MVP>


Thanks! but how did you know???

:

Sounds like the column widths property is not properly set. It should
be
this:

0";0";1"

Or use whatever width for the third colum that you want. Also be sure
that
the column count property is set to 3.

--

Ken Snell
<MS ACCESS MVP>

I have three tables defined at follows:

tblStore:
Primary Key: lngStoreID AutoNumber
strStoreName Text

tblManager:
Primary Key: lngManagerID AutoNumber
lngStoreID Number
strManagerName Text

tblEmployee:
Primary Key: lngEmployeeID AutoNumber
lngManagerID Number
strEmployeeName Text

I have 3 combo boxes, cboStore, cboManager, and cboEmployee

The AfterUpdate for cboStore is as follows and and the store picked
is
used
to filter the managers name that will display in cboManager

Private Sub cboStore_AfterUpdate()
Dim sManagerSource As String

sManagerSource = "SELECT [tblManager].[lngManagerID],
[tblManager].[lngStoreID], [tblManager].[strManagerName] " & _
"FROM tblManager " & _
"WHERE [lngStoreID] = " & Me.cboStore.Value
Me.cboManager.RowSource = sManagerSource
Me.cboManager.Requery
End Sub

The AfterUpdate for cboManager is as follows and the manager name
picked
is
used to filter the employee name that will display in cboEmployee

Private Sub cboManager_AfterUpdate()
Dim sEmployeeSource As String

sEmployeeSource = "SELECT
[tblEmployee].[lngEmployeeID],[tblEmployee].[lngManagerID],
[tblEmployee].[strEmployeeName] " & _
"FROM tblEmployee " & _
"WHERE [lngManagerID] = " &
Me.cboManager.Value
Me.cboEmployee.RowSource = sEmployeeSource
Me.cboEmployee.Requery
End Sub

The cboStore displays the strStoreName (Text), the cboManger
displays
the
strManagerName (Text) based on the store picked, but the
cboEmployee
displays
the lngMangaerID (Number) instead of the strEmployeeName (Text)..
What's
wrong??? Thanks..Joe.
 
K

Ken Snell \(MVP\)

The query would be something like this:

SELECT S.StoreName, M.ManagerName, E.EmployeeName
FROM ((YourTableName AS Y INNER JOIN StoreTable AS S
ON Y.Store.=S.StoreID) INNER JOIN ManagerTable AS M
ON Y.Manager = M.ManagerID) INNER JOIN
EmployeeTable AS E ON Y.Employee=E.EmployeeID;

--

Ken Snell
<MS ACCESS MVP>



Joe Leon said:
Thanks...

But I'm having a problem coming up with the query.

So far, from the form I created, the table is getting filled with the
following 4 records:

tblPickID | Store | Manager | Employee
1 | 1 | 1 | 2
2 | 2 | 4 | 9
3 | 3 | 6 | 18
4 | 4 | 8 | 16

And yes you're right all the values match as you say. But I'm having
problems coming up with the query. Thanks... Joe...



Ken Snell (MVP) said:
You should be storing the ID, not the name. The bound column of the combo
box is the column whose value is actually the value of the combo box. In
a
relational database, you store the related field value, and then you use
a
query to get the actual name when you want it for another form or report.

This means that you can update a store name in the store table, and not
need
to update it in all the other records where you'd stored a name instead
of
the StoreID.

So your setup is working correctly.
--

Ken Snell
<MS ACCESS MVP>




Joe Leon said:
Here's a follow on question.... Now that I have this working I tried
placing
the StoreName, ManagerName, and EmployeeName in a table after the combo
box
selction. But what I am storing is not the text but the ID. What am I
doing
wrong?
Thanks...Joe...

:

OK - second clue should say the first combo box not the second... but
still
lets me appear to be clairvoyant < g >
--

Ken Snell
<MS ACCESS MVP>



First clue was your statement that the cboEmployee combo box is
showing
the lngMangaerID, which is the second column in the Row Source
query.

Second clue was assuming that you probably copied the cboManager
combo
box
to make the cboEmployee combo box, and the cboManager combo box has
only
two columns in its RowSource query. Common error to forget to change
the
settings when doing this -- I've done it many times.

--

Ken Snell
<MS ACCESS MVP>


Thanks! but how did you know???

:

Sounds like the column widths property is not properly set. It
should
be
this:

0";0";1"

Or use whatever width for the third colum that you want. Also be
sure
that
the column count property is set to 3.

--

Ken Snell
<MS ACCESS MVP>

I have three tables defined at follows:

tblStore:
Primary Key: lngStoreID AutoNumber
strStoreName Text

tblManager:
Primary Key: lngManagerID AutoNumber
lngStoreID Number
strManagerName Text

tblEmployee:
Primary Key: lngEmployeeID AutoNumber
lngManagerID Number
strEmployeeName Text

I have 3 combo boxes, cboStore, cboManager, and cboEmployee

The AfterUpdate for cboStore is as follows and and the store
picked
is
used
to filter the managers name that will display in cboManager

Private Sub cboStore_AfterUpdate()
Dim sManagerSource As String

sManagerSource = "SELECT [tblManager].[lngManagerID],
[tblManager].[lngStoreID], [tblManager].[strManagerName] " & _
"FROM tblManager " & _
"WHERE [lngStoreID] = " &
Me.cboStore.Value
Me.cboManager.RowSource = sManagerSource
Me.cboManager.Requery
End Sub

The AfterUpdate for cboManager is as follows and the manager
name
picked
is
used to filter the employee name that will display in
cboEmployee

Private Sub cboManager_AfterUpdate()
Dim sEmployeeSource As String

sEmployeeSource = "SELECT
[tblEmployee].[lngEmployeeID],[tblEmployee].[lngManagerID],
[tblEmployee].[strEmployeeName] " & _
"FROM tblEmployee " & _
"WHERE [lngManagerID] = " &
Me.cboManager.Value
Me.cboEmployee.RowSource = sEmployeeSource
Me.cboEmployee.Requery
End Sub

The cboStore displays the strStoreName (Text), the cboManger
displays
the
strManagerName (Text) based on the store picked, but the
cboEmployee
displays
the lngMangaerID (Number) instead of the strEmployeeName
(Text)..
What's
wrong??? Thanks..Joe.
 
G

Guest

I'm confused. Here is what I have to now:
The three tables: tblStore, tblManager, tblEmployee that are used to extract
the data.
The tblPick is what is getting filled with the data from the combo boxes.

tblStore:
Primary Key: lngStoreID AutoNumber
strStoreName Text

tblManager:
Primary Key: lngManagerID AutoNumber
lngStoreID Number
strManagerName Text

tblEmployee:
Primary Key: lngEmployeeID AutoNumber
lngManagerID Number
strEmployeeName Text

tblPick
Primary Key: lngPickID AutoNumber
Store Text
Manager Text
Employee Text

Looking at the way you instruct how the query should be written, I have the
following, but, I'm confused with the Y, S, and M.

SELECT Store, Manager, Employee
FROM ((tblPick AS Y
INNER JOIN tblStore AS S
ON Y.Store.=S.StoreID)
INNER JOIN tblManager AS M
ON Y.Manager = M.ManagerID)
INNER JOIN
tblEmployee AS E ON Y.Employee=E.EmployeeID;

Ken Snell (MVP)" wrote:
The query would be something like this:

SELECT S.StoreName, M.ManagerName, E.EmployeeName
FROM ((YourTableName AS Y INNER JOIN StoreTable AS S
ON Y.Store.=S.StoreID) INNER JOIN ManagerTable AS M
ON Y.Manager = M.ManagerID) INNER JOIN
EmployeeTable AS E ON Y.Employee=E.EmployeeID;

--

Ken Snell
<MS ACCESS MVP>



Joe Leon said:
Thanks...

But I'm having a problem coming up with the query.

So far, from the form I created, the table is getting filled with the
following 4 records:

tblPickID | Store | Manager | Employee
1 | 1 | 1 | 2
2 | 2 | 4 | 9
3 | 3 | 6 | 18
4 | 4 | 8 | 16

And yes you're right all the values match as you say. But I'm having
problems coming up with the query. Thanks... Joe...



Ken Snell (MVP) said:
You should be storing the ID, not the name. The bound column of the combo
box is the column whose value is actually the value of the combo box. In
a
relational database, you store the related field value, and then you use
a
query to get the actual name when you want it for another form or report.

This means that you can update a store name in the store table, and not
need
to update it in all the other records where you'd stored a name instead
of
the StoreID.

So your setup is working correctly.
--

Ken Snell
<MS ACCESS MVP>




Here's a follow on question.... Now that I have this working I tried
placing
the StoreName, ManagerName, and EmployeeName in a table after the combo
box
selction. But what I am storing is not the text but the ID. What am I
doing
wrong?
Thanks...Joe...

:

OK - second clue should say the first combo box not the second... but
still
lets me appear to be clairvoyant < g >
--

Ken Snell
<MS ACCESS MVP>



First clue was your statement that the cboEmployee combo box is
showing
the lngMangaerID, which is the second column in the Row Source
query.

Second clue was assuming that you probably copied the cboManager
combo
box
to make the cboEmployee combo box, and the cboManager combo box has
only
two columns in its RowSource query. Common error to forget to change
the
settings when doing this -- I've done it many times.

--

Ken Snell
<MS ACCESS MVP>


Thanks! but how did you know???

:

Sounds like the column widths property is not properly set. It
should
be
this:

0";0";1"

Or use whatever width for the third colum that you want. Also be
sure
that
the column count property is set to 3.

--

Ken Snell
<MS ACCESS MVP>

I have three tables defined at follows:

tblStore:
Primary Key: lngStoreID AutoNumber
strStoreName Text

tblManager:
Primary Key: lngManagerID AutoNumber
lngStoreID Number
strManagerName Text

tblEmployee:
Primary Key: lngEmployeeID AutoNumber
lngManagerID Number
strEmployeeName Text

I have 3 combo boxes, cboStore, cboManager, and cboEmployee

The AfterUpdate for cboStore is as follows and and the store
picked
is
used
to filter the managers name that will display in cboManager

Private Sub cboStore_AfterUpdate()
Dim sManagerSource As String

sManagerSource = "SELECT [tblManager].[lngManagerID],
[tblManager].[lngStoreID], [tblManager].[strManagerName] " & _
"FROM tblManager " & _
"WHERE [lngStoreID] = " &
Me.cboStore.Value
Me.cboManager.RowSource = sManagerSource
Me.cboManager.Requery
End Sub

The AfterUpdate for cboManager is as follows and the manager
name
picked
is
used to filter the employee name that will display in
cboEmployee

Private Sub cboManager_AfterUpdate()
Dim sEmployeeSource As String

sEmployeeSource = "SELECT
[tblEmployee].[lngEmployeeID],[tblEmployee].[lngManagerID],
[tblEmployee].[strEmployeeName] " & _
"FROM tblEmployee " & _
"WHERE [lngManagerID] = " &
Me.cboManager.Value
Me.cboEmployee.RowSource = sEmployeeSource
Me.cboEmployee.Requery
End Sub

The cboStore displays the strStoreName (Text), the cboManger
displays
the
strManagerName (Text) based on the store picked, but the
cboEmployee
displays
the lngMangaerID (Number) instead of the strEmployeeName
(Text)..
What's
wrong??? Thanks..Joe.
 
K

Ken Snell \(MVP\)

The S, E, M, and Y are table aliases... shorthand references rather than
writing the entire table name each time.

You need to change the table structure for tblPick. The Store, Manager, and
Employee fields all need to be Number (long integer) data types, not text.
You need to make these changes so that the query will work.

OK, the query would be something like this:

SELECT S.strStoreName, M.strManagerName, E.strEmployeeName
FROM ((tblPick AS Y
INNER JOIN tblStore AS S
ON Y.Store.=S.lngStoreID )
INNER JOIN tblManager AS M
ON Y.Manager = M.lngManagerID)
INNER JOIN
tblEmployee AS E ON Y.Employee=E.lngEmployeeID;

--

Ken Snell
<MS ACCESS MVP>



Joe Leon said:
I'm confused. Here is what I have to now:
The three tables: tblStore, tblManager, tblEmployee that are used to
extract
the data.
The tblPick is what is getting filled with the data from the combo boxes.

tblStore:
Primary Key: lngStoreID AutoNumber
strStoreName Text

tblManager:
Primary Key: lngManagerID AutoNumber
lngStoreID Number
strManagerName Text

tblEmployee:
Primary Key: lngEmployeeID AutoNumber
lngManagerID Number
strEmployeeName Text

tblPick
Primary Key: lngPickID AutoNumber
Store Text
Manager Text
Employee Text

Looking at the way you instruct how the query should be written, I have
the
following, but, I'm confused with the Y, S, and M.

SELECT Store, Manager, Employee
FROM ((tblPick AS Y
INNER JOIN tblStore AS S
ON Y.Store.=S.StoreID)
INNER JOIN tblManager AS M
ON Y.Manager = M.ManagerID)
INNER JOIN
tblEmployee AS E ON Y.Employee=E.EmployeeID;

Ken Snell (MVP)" wrote:
The query would be something like this:

SELECT S.StoreName, M.ManagerName, E.EmployeeName
FROM ((YourTableName AS Y INNER JOIN StoreTable AS S
ON Y.Store.=S.StoreID) INNER JOIN ManagerTable AS M
ON Y.Manager = M.ManagerID) INNER JOIN
EmployeeTable AS E ON Y.Employee=E.EmployeeID;

--

Ken Snell
<MS ACCESS MVP>



Joe Leon said:
Thanks...

But I'm having a problem coming up with the query.

So far, from the form I created, the table is getting filled with the
following 4 records:

tblPickID | Store | Manager | Employee
1 | 1 | 1 | 2
2 | 2 | 4 | 9
3 | 3 | 6 | 18
4 | 4 | 8 | 16

And yes you're right all the values match as you say. But I'm having
problems coming up with the query. Thanks... Joe...



:

You should be storing the ID, not the name. The bound column of the
combo
box is the column whose value is actually the value of the combo box.
In
a
relational database, you store the related field value, and then you
use
a
query to get the actual name when you want it for another form or
report.

This means that you can update a store name in the store table, and
not
need
to update it in all the other records where you'd stored a name
instead
of
the StoreID.

So your setup is working correctly.
--

Ken Snell
<MS ACCESS MVP>




Here's a follow on question.... Now that I have this working I
tried
placing
the StoreName, ManagerName, and EmployeeName in a table after the
combo
box
selction. But what I am storing is not the text but the ID. What am
I
doing
wrong?
Thanks...Joe...

:

OK - second clue should say the first combo box not the second...
but
still
lets me appear to be clairvoyant < g >
--

Ken Snell
<MS ACCESS MVP>



message
First clue was your statement that the cboEmployee combo box is
showing
the lngMangaerID, which is the second column in the Row Source
query.

Second clue was assuming that you probably copied the cboManager
combo
box
to make the cboEmployee combo box, and the cboManager combo box
has
only
two columns in its RowSource query. Common error to forget to
change
the
settings when doing this -- I've done it many times.

--

Ken Snell
<MS ACCESS MVP>


Thanks! but how did you know???

:

Sounds like the column widths property is not properly set. It
should
be
this:

0";0";1"

Or use whatever width for the third colum that you want. Also
be
sure
that
the column count property is set to 3.

--

Ken Snell
<MS ACCESS MVP>

I have three tables defined at follows:

tblStore:
Primary Key: lngStoreID AutoNumber
strStoreName Text

tblManager:
Primary Key: lngManagerID AutoNumber
lngStoreID Number
strManagerName Text

tblEmployee:
Primary Key: lngEmployeeID AutoNumber
lngManagerID Number
strEmployeeName Text

I have 3 combo boxes, cboStore, cboManager, and cboEmployee

The AfterUpdate for cboStore is as follows and and the store
picked
is
used
to filter the managers name that will display in cboManager

Private Sub cboStore_AfterUpdate()
Dim sManagerSource As String

sManagerSource = "SELECT [tblManager].[lngManagerID],
[tblManager].[lngStoreID], [tblManager].[strManagerName] " &
_
"FROM tblManager " & _
"WHERE [lngStoreID] = " &
Me.cboStore.Value
Me.cboManager.RowSource = sManagerSource
Me.cboManager.Requery
End Sub

The AfterUpdate for cboManager is as follows and the manager
name
picked
is
used to filter the employee name that will display in
cboEmployee

Private Sub cboManager_AfterUpdate()
Dim sEmployeeSource As String

sEmployeeSource = "SELECT
[tblEmployee].[lngEmployeeID],[tblEmployee].[lngManagerID],
[tblEmployee].[strEmployeeName] " & _
"FROM tblEmployee " & _
"WHERE [lngManagerID] = " &
Me.cboManager.Value
Me.cboEmployee.RowSource = sEmployeeSource
Me.cboEmployee.Requery
End Sub

The cboStore displays the strStoreName (Text), the cboManger
displays
the
strManagerName (Text) based on the store picked, but the
cboEmployee
displays
the lngMangaerID (Number) instead of the strEmployeeName
(Text)..
What's
wrong??? Thanks..Joe.
 
G

Guest

Thank you so much for your explanations and kindness in helping me with this.

Ken Snell (MVP) said:
The S, E, M, and Y are table aliases... shorthand references rather than
writing the entire table name each time.

You need to change the table structure for tblPick. The Store, Manager, and
Employee fields all need to be Number (long integer) data types, not text.
You need to make these changes so that the query will work.

OK, the query would be something like this:

SELECT S.strStoreName, M.strManagerName, E.strEmployeeName
FROM ((tblPick AS Y
INNER JOIN tblStore AS S
ON Y.Store.=S.lngStoreID )
INNER JOIN tblManager AS M
ON Y.Manager = M.lngManagerID)
INNER JOIN
tblEmployee AS E ON Y.Employee=E.lngEmployeeID;

--

Ken Snell
<MS ACCESS MVP>



Joe Leon said:
I'm confused. Here is what I have to now:
The three tables: tblStore, tblManager, tblEmployee that are used to
extract
the data.
The tblPick is what is getting filled with the data from the combo boxes.

tblStore:
Primary Key: lngStoreID AutoNumber
strStoreName Text

tblManager:
Primary Key: lngManagerID AutoNumber
lngStoreID Number
strManagerName Text

tblEmployee:
Primary Key: lngEmployeeID AutoNumber
lngManagerID Number
strEmployeeName Text

tblPick
Primary Key: lngPickID AutoNumber
Store Text
Manager Text
Employee Text

Looking at the way you instruct how the query should be written, I have
the
following, but, I'm confused with the Y, S, and M.

SELECT Store, Manager, Employee
FROM ((tblPick AS Y
INNER JOIN tblStore AS S
ON Y.Store.=S.StoreID)
INNER JOIN tblManager AS M
ON Y.Manager = M.ManagerID)
INNER JOIN
tblEmployee AS E ON Y.Employee=E.EmployeeID;

Ken Snell (MVP)" wrote:
The query would be something like this:

SELECT S.StoreName, M.ManagerName, E.EmployeeName
FROM ((YourTableName AS Y INNER JOIN StoreTable AS S
ON Y.Store.=S.StoreID) INNER JOIN ManagerTable AS M
ON Y.Manager = M.ManagerID) INNER JOIN
EmployeeTable AS E ON Y.Employee=E.EmployeeID;

--

Ken Snell
<MS ACCESS MVP>



Thanks...

But I'm having a problem coming up with the query.

So far, from the form I created, the table is getting filled with the
following 4 records:

tblPickID | Store | Manager | Employee
1 | 1 | 1 | 2
2 | 2 | 4 | 9
3 | 3 | 6 | 18
4 | 4 | 8 | 16

And yes you're right all the values match as you say. But I'm having
problems coming up with the query. Thanks... Joe...



:

You should be storing the ID, not the name. The bound column of the
combo
box is the column whose value is actually the value of the combo box.
In
a
relational database, you store the related field value, and then you
use
a
query to get the actual name when you want it for another form or
report.

This means that you can update a store name in the store table, and
not
need
to update it in all the other records where you'd stored a name
instead
of
the StoreID.

So your setup is working correctly.
--

Ken Snell
<MS ACCESS MVP>




Here's a follow on question.... Now that I have this working I
tried
placing
the StoreName, ManagerName, and EmployeeName in a table after the
combo
box
selction. But what I am storing is not the text but the ID. What am
I
doing
wrong?
Thanks...Joe...

:

OK - second clue should say the first combo box not the second...
but
still
lets me appear to be clairvoyant < g >
--

Ken Snell
<MS ACCESS MVP>



message
First clue was your statement that the cboEmployee combo box is
showing
the lngMangaerID, which is the second column in the Row Source
query.

Second clue was assuming that you probably copied the cboManager
combo
box
to make the cboEmployee combo box, and the cboManager combo box
has
only
two columns in its RowSource query. Common error to forget to
change
the
settings when doing this -- I've done it many times.

--

Ken Snell
<MS ACCESS MVP>


Thanks! but how did you know???

:

Sounds like the column widths property is not properly set. It
should
be
this:

0";0";1"

Or use whatever width for the third colum that you want. Also
be
sure
that
the column count property is set to 3.

--

Ken Snell
<MS ACCESS MVP>

I have three tables defined at follows:

tblStore:
Primary Key: lngStoreID AutoNumber
strStoreName Text

tblManager:
Primary Key: lngManagerID AutoNumber
lngStoreID Number
strManagerName Text

tblEmployee:
Primary Key: lngEmployeeID AutoNumber
lngManagerID Number
strEmployeeName Text

I have 3 combo boxes, cboStore, cboManager, and cboEmployee

The AfterUpdate for cboStore is as follows and and the store
picked
is
used
to filter the managers name that will display in cboManager

Private Sub cboStore_AfterUpdate()
Dim sManagerSource As String

sManagerSource = "SELECT [tblManager].[lngManagerID],
[tblManager].[lngStoreID], [tblManager].[strManagerName] " &
_
"FROM tblManager " & _
"WHERE [lngStoreID] = " &
Me.cboStore.Value
Me.cboManager.RowSource = sManagerSource
Me.cboManager.Requery
End Sub

The AfterUpdate for cboManager is as follows and the manager
name
picked
is
used to filter the employee name that will display in
cboEmployee

Private Sub cboManager_AfterUpdate()
Dim sEmployeeSource As String

sEmployeeSource = "SELECT
[tblEmployee].[lngEmployeeID],[tblEmployee].[lngManagerID],
[tblEmployee].[strEmployeeName] " & _
"FROM tblEmployee " & _
"WHERE [lngManagerID] = " &
Me.cboManager.Value
Me.cboEmployee.RowSource = sEmployeeSource
Me.cboEmployee.Requery
End Sub

The cboStore displays the strStoreName (Text), the cboManger
displays
the
strManagerName (Text) based on the store picked, but the
cboEmployee
displays
the lngMangaerID (Number) instead of the strEmployeeName
(Text)..
What's
wrong??? Thanks..Joe.
 
G

Guest

It's been a while.... just got back from a trip and started working on this
again...
Here is the problem I have. All seems to work ok except that when I write
the record go to the next record and come back to the first one, the list
boxes are not displaying the data. I know the data is there because the query
shows it. What am I doing wrong?
 
K

Ken Snell \(MVP\)

You probably need to requery the listbox in the form's Current event
procedure:

Private Sub Form_Current()
Me.NameofListBox.Requery
End Sub


I don't recall the exact setup on your form, so this advice may be a bit off
the mark. Let me know if it is.
 
G

Guest

Below is the code for the form for both AfterUpdates and Current.
--------------------------------------------
Private Sub cboManager_AfterUpdate()
Dim sEmployeeSource As String

sEmployeeSource = "SELECT
[tblEmployee].[lngEmployeeID],[tblEmployee].[lngManagerID],
[tblEmployee].[strEmployeeName] " & _
"FROM tblEmployee " & _
"WHERE [lngManagerID] = " & Me.cboManager.Value
Me.cboEmployee.RowSource = sEmployeeSource
Me.cboEmployee.Requery
End Sub
-------------------------------------------
Private Sub cboStore_AfterUpdate()
Dim sManagerSource As String

sManagerSource = "SELECT [tblManager].[lngManagerID],
[tblManager].[lngStoreID], [tblManager].[strManagerName] " & _
"FROM tblManager " & _
"WHERE [lngStoreID] = " & Me.cboStore.Value
Me.cboManager.RowSource = sManagerSource
End Sub
------------------------------------------
Private Sub Form_Current()
Me.cboStore.Requery
Me.cboManager.Requery
Me.cboEmployee.Requery
End Sub

I inserted in the form's Current event the code above, but display is not
refreshing the listbox.
 
K

Ken Snell \(MVP\)

Aha, because you're generating the SQL statement dynamically, you hardcode
the value for the WHERE test into the string. Doing a requery will not cause
the combo box (not list box) to synch with the current record.

Let's just rerun the AfterUpdate event procedures in the form's Current
event:

Private Sub Form_Current()
Call cboStore_AfterUpdate
Call cboManager_AfterUpdate
End Sub


--

Ken Snell
<MS ACCESS MVP>



Joe Leon said:
Below is the code for the form for both AfterUpdates and Current.
--------------------------------------------
Private Sub cboManager_AfterUpdate()
Dim sEmployeeSource As String

sEmployeeSource = "SELECT
[tblEmployee].[lngEmployeeID],[tblEmployee].[lngManagerID],
[tblEmployee].[strEmployeeName] " & _
"FROM tblEmployee " & _
"WHERE [lngManagerID] = " & Me.cboManager.Value
Me.cboEmployee.RowSource = sEmployeeSource
Me.cboEmployee.Requery
End Sub
-------------------------------------------
Private Sub cboStore_AfterUpdate()
Dim sManagerSource As String

sManagerSource = "SELECT [tblManager].[lngManagerID],
[tblManager].[lngStoreID], [tblManager].[strManagerName] " & _
"FROM tblManager " & _
"WHERE [lngStoreID] = " & Me.cboStore.Value
Me.cboManager.RowSource = sManagerSource
End Sub
------------------------------------------
Private Sub Form_Current()
Me.cboStore.Requery
Me.cboManager.Requery
Me.cboEmployee.Requery
End Sub

I inserted in the form's Current event the code above, but display is not
refreshing the listbox.

Ken Snell (MVP) said:
You probably need to requery the listbox in the form's Current event
procedure:

Private Sub Form_Current()
Me.NameofListBox.Requery
End Sub


I don't recall the exact setup on your form, so this advice may be a bit
off
the mark. Let me know if it is.
 
G

Guest

I tried your suggestion:
Private Sub Form_Current()
Call cboStore_AfterUpdate
Call cboManager_AfterUpdate
End Sub

What I'm seeing now is

1. When the form opens sometimes the cboManger is not displayed (blank).
2. When I go to the next record, sometimes the cboManger is displayed. but
most of the time is not displayed.

The cboStore and cboEmployee display fine.

Ken Snell (MVP) said:
Aha, because you're generating the SQL statement dynamically, you hardcode
the value for the WHERE test into the string. Doing a requery will not cause
the combo box (not list box) to synch with the current record.

Let's just rerun the AfterUpdate event procedures in the form's Current
event:

Private Sub Form_Current()
Call cboStore_AfterUpdate
Call cboManager_AfterUpdate
End Sub


--

Ken Snell
<MS ACCESS MVP>



Joe Leon said:
Below is the code for the form for both AfterUpdates and Current.
--------------------------------------------
Private Sub cboManager_AfterUpdate()
Dim sEmployeeSource As String

sEmployeeSource = "SELECT
[tblEmployee].[lngEmployeeID],[tblEmployee].[lngManagerID],
[tblEmployee].[strEmployeeName] " & _
"FROM tblEmployee " & _
"WHERE [lngManagerID] = " & Me.cboManager.Value
Me.cboEmployee.RowSource = sEmployeeSource
Me.cboEmployee.Requery
End Sub
-------------------------------------------
Private Sub cboStore_AfterUpdate()
Dim sManagerSource As String

sManagerSource = "SELECT [tblManager].[lngManagerID],
[tblManager].[lngStoreID], [tblManager].[strManagerName] " & _
"FROM tblManager " & _
"WHERE [lngStoreID] = " & Me.cboStore.Value
Me.cboManager.RowSource = sManagerSource
End Sub
------------------------------------------
Private Sub Form_Current()
Me.cboStore.Requery
Me.cboManager.Requery
Me.cboEmployee.Requery
End Sub

I inserted in the form's Current event the code above, but display is not
refreshing the listbox.

Ken Snell (MVP) said:
You probably need to requery the listbox in the form's Current event
procedure:

Private Sub Form_Current()
Me.NameofListBox.Requery
End Sub


I don't recall the exact setup on your form, so this advice may be a bit
off
the mark. Let me know if it is.
--

Ken Snell
<MS ACCESS MVP>


It's been a while.... just got back from a trip and started working on
this
again...
Here is the problem I have. All seems to work ok except that when I
write
the record go to the next record and come back to the first one, the
list
boxes are not displaying the data. I know the data is there because the
query
shows it. What am I doing wrong?

:

You're welcome; good luck.

--

Ken Snell
<MS ACCESS MVP>

Thank you so much for your explanations and kindness in helping me
with
this.
 
K

Ken Snell \(MVP\)

Might be a timing issue. Try inserting DoEvents steps to let the form catch
up:


Private Sub Form_Current()
Dim lngLoop As Long
Call cboStore_AfterUpdate
For lngLoop = 1 To 20
DoEvents
Next lngLoop
Call cboManager_AfterUpdate
End Sub

--

Ken Snell
<MS ACCESS MVP>


Joe Leon said:
I tried your suggestion:
Private Sub Form_Current()
Call cboStore_AfterUpdate
Call cboManager_AfterUpdate
End Sub

What I'm seeing now is

1. When the form opens sometimes the cboManger is not displayed (blank).
2. When I go to the next record, sometimes the cboManger is displayed. but
most of the time is not displayed.

The cboStore and cboEmployee display fine.

Ken Snell (MVP) said:
Aha, because you're generating the SQL statement dynamically, you
hardcode
the value for the WHERE test into the string. Doing a requery will not
cause
the combo box (not list box) to synch with the current record.

Let's just rerun the AfterUpdate event procedures in the form's Current
event:

Private Sub Form_Current()
Call cboStore_AfterUpdate
Call cboManager_AfterUpdate
End Sub


--

Ken Snell
<MS ACCESS MVP>



Joe Leon said:
Below is the code for the form for both AfterUpdates and Current.
--------------------------------------------
Private Sub cboManager_AfterUpdate()
Dim sEmployeeSource As String

sEmployeeSource = "SELECT
[tblEmployee].[lngEmployeeID],[tblEmployee].[lngManagerID],
[tblEmployee].[strEmployeeName] " & _
"FROM tblEmployee " & _
"WHERE [lngManagerID] = " & Me.cboManager.Value
Me.cboEmployee.RowSource = sEmployeeSource
Me.cboEmployee.Requery
End Sub
-------------------------------------------
Private Sub cboStore_AfterUpdate()
Dim sManagerSource As String

sManagerSource = "SELECT [tblManager].[lngManagerID],
[tblManager].[lngStoreID], [tblManager].[strManagerName] " & _
"FROM tblManager " & _
"WHERE [lngStoreID] = " & Me.cboStore.Value
Me.cboManager.RowSource = sManagerSource
End Sub
------------------------------------------
Private Sub Form_Current()
Me.cboStore.Requery
Me.cboManager.Requery
Me.cboEmployee.Requery
End Sub

I inserted in the form's Current event the code above, but display is
not
refreshing the listbox.

:

You probably need to requery the listbox in the form's Current event
procedure:

Private Sub Form_Current()
Me.NameofListBox.Requery
End Sub


I don't recall the exact setup on your form, so this advice may be a
bit
off
the mark. Let me know if it is.
--

Ken Snell
<MS ACCESS MVP>


It's been a while.... just got back from a trip and started working
on
this
again...
Here is the problem I have. All seems to work ok except that when I
write
the record go to the next record and come back to the first one, the
list
boxes are not displaying the data. I know the data is there because
the
query
shows it. What am I doing wrong?

:

You're welcome; good luck.

--

Ken Snell
<MS ACCESS MVP>

Thank you so much for your explanations and kindness in helping
me
with
this.
 
G

Guest

That's what it was.. a timing issue.. THANKS !!

Ken Snell (MVP) said:
Might be a timing issue. Try inserting DoEvents steps to let the form catch
up:


Private Sub Form_Current()
Dim lngLoop As Long
Call cboStore_AfterUpdate
For lngLoop = 1 To 20
DoEvents
Next lngLoop
Call cboManager_AfterUpdate
End Sub

--

Ken Snell
<MS ACCESS MVP>


Joe Leon said:
I tried your suggestion:
Private Sub Form_Current()
Call cboStore_AfterUpdate
Call cboManager_AfterUpdate
End Sub

What I'm seeing now is

1. When the form opens sometimes the cboManger is not displayed (blank).
2. When I go to the next record, sometimes the cboManger is displayed. but
most of the time is not displayed.

The cboStore and cboEmployee display fine.

Ken Snell (MVP) said:
Aha, because you're generating the SQL statement dynamically, you
hardcode
the value for the WHERE test into the string. Doing a requery will not
cause
the combo box (not list box) to synch with the current record.

Let's just rerun the AfterUpdate event procedures in the form's Current
event:

Private Sub Form_Current()
Call cboStore_AfterUpdate
Call cboManager_AfterUpdate
End Sub


--

Ken Snell
<MS ACCESS MVP>



Below is the code for the form for both AfterUpdates and Current.
--------------------------------------------
Private Sub cboManager_AfterUpdate()
Dim sEmployeeSource As String

sEmployeeSource = "SELECT
[tblEmployee].[lngEmployeeID],[tblEmployee].[lngManagerID],
[tblEmployee].[strEmployeeName] " & _
"FROM tblEmployee " & _
"WHERE [lngManagerID] = " & Me.cboManager.Value
Me.cboEmployee.RowSource = sEmployeeSource
Me.cboEmployee.Requery
End Sub
-------------------------------------------
Private Sub cboStore_AfterUpdate()
Dim sManagerSource As String

sManagerSource = "SELECT [tblManager].[lngManagerID],
[tblManager].[lngStoreID], [tblManager].[strManagerName] " & _
"FROM tblManager " & _
"WHERE [lngStoreID] = " & Me.cboStore.Value
Me.cboManager.RowSource = sManagerSource
End Sub
------------------------------------------
Private Sub Form_Current()
Me.cboStore.Requery
Me.cboManager.Requery
Me.cboEmployee.Requery
End Sub

I inserted in the form's Current event the code above, but display is
not
refreshing the listbox.

:

You probably need to requery the listbox in the form's Current event
procedure:

Private Sub Form_Current()
Me.NameofListBox.Requery
End Sub


I don't recall the exact setup on your form, so this advice may be a
bit
off
the mark. Let me know if it is.
--

Ken Snell
<MS ACCESS MVP>


It's been a while.... just got back from a trip and started working
on
this
again...
Here is the problem I have. All seems to work ok except that when I
write
the record go to the next record and come back to the first one, the
list
boxes are not displaying the data. I know the data is there because
the
query
shows it. What am I doing wrong?

:

You're welcome; good luck.

--

Ken Snell
<MS ACCESS MVP>

Thank you so much for your explanations and kindness in helping
me
with
this.
 

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