Dynamic field data population

I

ImJoe

Hi,

I'm new to Access Form and I've asked a similar question without meaningful
result, ENV: Access 2003. Here I'll give it another shot.

The question is, I have a form, say, field A shows a list of companies, its
data is generated by a query like
Select companyID, companName
From company
then, upon selection of a particular company,
field B would display a list of products provided by this company, so, the
query would look like this:
Select productID, productName
From product
Where companyID = {thePreviouslySelectedCompanyID}

It should be fairly simple. How can I accomplish the above?

Thanks a bunch in advance.
 
O

Ofer

You can link the rowsource of list2 to the selection of list1

Select productID, productName
From product
Where companyID = Forms![MainFormName]![List1Name]

On the after update event of list 1, you need to refresh list2 by adding the
code in the code section

me.list2.requery
 
I

ImJoe

Thank you very much. I've have been fumbling with it for the last forty
minutes or so trying different things, however, to no avail.

Testing of the following query also failed with Access 2003 (first prompted
from companyID then produced no records)
Select productID, productName
From product
Where companyID = Forms![MainFormName]![List1Name]

However, the above query behaved differently with Access 97,
I was first prompted with companyID, then, Forms![MainFormName]![List1Name].

Am I missing some required components (like library) for Access 2003?

Again thanks.


Ofer said:
You can link the rowsource of list2 to the selection of list1

Select productID, productName
From product
Where companyID = Forms![MainFormName]![List1Name]

On the after update event of list 1, you need to refresh list2 by adding the
code in the code section

me.list2.requery


ImJoe said:
Hi,

I'm new to Access Form and I've asked a similar question without meaningful
result, ENV: Access 2003. Here I'll give it another shot.

The question is, I have a form, say, field A shows a list of companies, its
data is generated by a query like
Select companyID, companName
From company
then, upon selection of a particular company,
field B would display a list of products provided by this company, so, the
query would look like this:
Select productID, productName
From product
Where companyID = {thePreviouslySelectedCompanyID}

It should be fairly simple. How can I accomplish the above?

Thanks a bunch in advance.
 
O

Ofer

Dont write the SQL as I gave you, change it to suit your details

Select productID, productName
From product
Where companyID = Forms![MainFormName]![List1Name]

MainFormName= The name of your form
List1Name = the name of the list within the form
companyID = The Company Id Field name in the table


ImJoe said:
Thank you very much. I've have been fumbling with it for the last forty
minutes or so trying different things, however, to no avail.

Testing of the following query also failed with Access 2003 (first prompted
from companyID then produced no records)
Select productID, productName
From product
Where companyID = Forms![MainFormName]![List1Name]

However, the above query behaved differently with Access 97,
I was first prompted with companyID, then, Forms![MainFormName]![List1Name].

Am I missing some required components (like library) for Access 2003?

Again thanks.


Ofer said:
You can link the rowsource of list2 to the selection of list1

Select productID, productName
From product
Where companyID = Forms![MainFormName]![List1Name]

On the after update event of list 1, you need to refresh list2 by adding the
code in the code section

me.list2.requery


ImJoe said:
Hi,

I'm new to Access Form and I've asked a similar question without meaningful
result, ENV: Access 2003. Here I'll give it another shot.

The question is, I have a form, say, field A shows a list of companies, its
data is generated by a query like
Select companyID, companName
From company
then, upon selection of a particular company,
field B would display a list of products provided by this company, so, the
query would look like this:
Select productID, productName
From product
Where companyID = {thePreviouslySelectedCompanyID}

It should be fairly simple. How can I accomplish the above?

Thanks a bunch in advance.
 
I

ImJoe

I certainly did not copy and paste your sample code. What could cause the
problem?
fyi, the Access 2003 was not intalled by me.

Ofer said:
Dont write the SQL as I gave you, change it to suit your details

Select productID, productName
From product
Where companyID = Forms![MainFormName]![List1Name]

MainFormName= The name of your form
List1Name = the name of the list within the form
companyID = The Company Id Field name in the table


ImJoe said:
Thank you very much. I've have been fumbling with it for the last forty
minutes or so trying different things, however, to no avail.

Testing of the following query also failed with Access 2003 (first prompted
from companyID then produced no records)
Select productID, productName
From product
Where companyID = Forms![MainFormName]![List1Name]

However, the above query behaved differently with Access 97,
I was first prompted with companyID, then, Forms![MainFormName]![List1Name].

Am I missing some required components (like library) for Access 2003?

Again thanks.


Ofer said:
You can link the rowsource of list2 to the selection of list1

Select productID, productName
From product
Where companyID = Forms![MainFormName]![List1Name]

On the after update event of list 1, you need to refresh list2 by adding the
code in the code section

me.list2.requery


:

Hi,

I'm new to Access Form and I've asked a similar question without meaningful
result, ENV: Access 2003. Here I'll give it another shot.

The question is, I have a form, say, field A shows a list of companies, its
data is generated by a query like
Select companyID, companName
From company
then, upon selection of a particular company,
field B would display a list of products provided by this company, so, the
query would look like this:
Select productID, productName
From product
Where companyID = {thePreviouslySelectedCompanyID}

It should be fairly simple. How can I accomplish the above?

Thanks a bunch in advance.
 
O

Ofer

What is the name of the form, and the name of the field?
When you run the query, the form should be open.


ImJoe said:
I certainly did not copy and paste your sample code. What could cause the
problem?
fyi, the Access 2003 was not intalled by me.

Ofer said:
Dont write the SQL as I gave you, change it to suit your details

Select productID, productName
From product
Where companyID = Forms![MainFormName]![List1Name]

MainFormName= The name of your form
List1Name = the name of the list within the form
companyID = The Company Id Field name in the table


ImJoe said:
Thank you very much. I've have been fumbling with it for the last forty
minutes or so trying different things, however, to no avail.

Testing of the following query also failed with Access 2003 (first prompted
from companyID then produced no records)
Select productID, productName
From product
Where companyID = Forms![MainFormName]![List1Name]

However, the above query behaved differently with Access 97,
I was first prompted with companyID, then, Forms![MainFormName]![List1Name].

Am I missing some required components (like library) for Access 2003?

Again thanks.


:

You can link the rowsource of list2 to the selection of list1

Select productID, productName
From product
Where companyID = Forms![MainFormName]![List1Name]

On the after update event of list 1, you need to refresh list2 by adding the
code in the code section

me.list2.requery


:

Hi,

I'm new to Access Form and I've asked a similar question without meaningful
result, ENV: Access 2003. Here I'll give it another shot.

The question is, I have a form, say, field A shows a list of companies, its
data is generated by a query like
Select companyID, companName
From company
then, upon selection of a particular company,
field B would display a list of products provided by this company, so, the
query would look like this:
Select productID, productName
From product
Where companyID = {thePreviouslySelectedCompanyID}

It should be fairly simple. How can I accomplish the above?

Thanks a bunch in advance.
 
I

ImJoe

I do appreciate your help, however, I'm not sure if it's ethical for me to
post a client's proprietory info here (fyi, Access upgrade is a part of the
project I'm tasked to perform). So, forgive me for not being very
straightforward with you. But let me do my best to present the problem here.
It's a quotation application. Now, when I take a close look, I realize that
the main form has subforms as well. Here's
code with my comment upfront:
main form name = frmQuoteII
fieldA or sub in this form = text344
fieldB or sub in this form = text346
fieldA or sub in the subform = cmbMfg 'correspond to text344
fieldB or sub in the subform = cmbSize 'correspond to text346

I noticed that Access 2003 was trying to perform some calculation (querying)
after fieldA is selected from the main form, but failed to populate fieldB in
the main form,
if it's driven from subform then that fails.

'main form
'BeforeUpdate
Private Sub Text344_BeforeUpdate(Cancel As Integer)

End Sub

Private Sub Text346_BeforeUpdate(Cancel As Integer)

End Sub

'AfterUpdate
Private Sub Text344_AfterUpdate()
' I (ImJoe) added the following line per your(Ofer) instruction
Me.Text346.Requery
End Sub

Private Sub Text344_BeforeUpdate(Cancel As Integer)

End Sub

Private Sub Text346_BeforeUpdate(Cancel As Integer)

End Sub

-----------------------

' subform
'BeforeUpdate
Private Sub cmbMfg_BeforeUpdate(Cancel As Integer)

End Sub

' no reference of the second field in the subform

'AfterUpdate
Private Sub cmbMFG_AfterUpdate()
cmbSize.Requery
txt207.Value = cmbMfg
Forms!frmQuoteII.Text344 = cmbMfg
' following line is new by DL
' Forms!frmQuoteII.Text346 = cmbSize

End Sub

Private Sub cmbSize_AfterUpdate()
cmbType.Requery
txt209.Value = cmbSize
Forms!frmQuoteII.Text346 = cmbSize
End Sub

Thank you very much.

Ofer said:
What is the name of the form, and the name of the field?
When you run the query, the form should be open.


ImJoe said:
I certainly did not copy and paste your sample code. What could cause the
problem?
fyi, the Access 2003 was not intalled by me.

Ofer said:
Dont write the SQL as I gave you, change it to suit your details

Select productID, productName
From product
Where companyID = Forms![MainFormName]![List1Name]

MainFormName= The name of your form
List1Name = the name of the list within the form
companyID = The Company Id Field name in the table


:

Thank you very much. I've have been fumbling with it for the last forty
minutes or so trying different things, however, to no avail.

Testing of the following query also failed with Access 2003 (first prompted
from companyID then produced no records)
Select productID, productName
From product
Where companyID = Forms![MainFormName]![List1Name]

However, the above query behaved differently with Access 97,
I was first prompted with companyID, then, Forms![MainFormName]![List1Name].

Am I missing some required components (like library) for Access 2003?

Again thanks.


:

You can link the rowsource of list2 to the selection of list1

Select productID, productName
From product
Where companyID = Forms![MainFormName]![List1Name]

On the after update event of list 1, you need to refresh list2 by adding the
code in the code section

me.list2.requery


:

Hi,

I'm new to Access Form and I've asked a similar question without meaningful
result, ENV: Access 2003. Here I'll give it another shot.

The question is, I have a form, say, field A shows a list of companies, its
data is generated by a query like
Select companyID, companName
From company
then, upon selection of a particular company,
field B would display a list of products provided by this company, so, the
query would look like this:
Select productID, productName
From product
Where companyID = {thePreviouslySelectedCompanyID}

It should be fairly simple. How can I accomplish the above?

Thanks a bunch in advance.
 
I

ImJoe

Ofer, any idea? thks.

ImJoe said:
I do appreciate your help, however, I'm not sure if it's ethical for me to
post a client's proprietory info here (fyi, Access upgrade is a part of the
project I'm tasked to perform). So, forgive me for not being very
straightforward with you. But let me do my best to present the problem here.
It's a quotation application. Now, when I take a close look, I realize that
the main form has subforms as well. Here's
code with my comment upfront:
main form name = frmQuoteII
fieldA or sub in this form = text344
fieldB or sub in this form = text346
fieldA or sub in the subform = cmbMfg 'correspond to text344
fieldB or sub in the subform = cmbSize 'correspond to text346

I noticed that Access 2003 was trying to perform some calculation (querying)
after fieldA is selected from the main form, but failed to populate fieldB in
the main form,
if it's driven from subform then that fails.

'main form
'BeforeUpdate
Private Sub Text344_BeforeUpdate(Cancel As Integer)

End Sub

Private Sub Text346_BeforeUpdate(Cancel As Integer)

End Sub

'AfterUpdate
Private Sub Text344_AfterUpdate()
' I (ImJoe) added the following line per your(Ofer) instruction
Me.Text346.Requery
End Sub

Private Sub Text344_BeforeUpdate(Cancel As Integer)

End Sub

Private Sub Text346_BeforeUpdate(Cancel As Integer)

End Sub

-----------------------

' subform
'BeforeUpdate
Private Sub cmbMfg_BeforeUpdate(Cancel As Integer)

End Sub

' no reference of the second field in the subform

'AfterUpdate
Private Sub cmbMFG_AfterUpdate()
cmbSize.Requery
txt207.Value = cmbMfg
Forms!frmQuoteII.Text344 = cmbMfg
' following line is new by DL
' Forms!frmQuoteII.Text346 = cmbSize

End Sub

Private Sub cmbSize_AfterUpdate()
cmbType.Requery
txt209.Value = cmbSize
Forms!frmQuoteII.Text346 = cmbSize
End Sub

Thank you very much.

Ofer said:
What is the name of the form, and the name of the field?
When you run the query, the form should be open.


ImJoe said:
I certainly did not copy and paste your sample code. What could cause the
problem?
fyi, the Access 2003 was not intalled by me.

:

Dont write the SQL as I gave you, change it to suit your details

Select productID, productName
From product
Where companyID = Forms![MainFormName]![List1Name]

MainFormName= The name of your form
List1Name = the name of the list within the form
companyID = The Company Id Field name in the table


:

Thank you very much. I've have been fumbling with it for the last forty
minutes or so trying different things, however, to no avail.

Testing of the following query also failed with Access 2003 (first prompted
from companyID then produced no records)
Select productID, productName
From product
Where companyID = Forms![MainFormName]![List1Name]

However, the above query behaved differently with Access 97,
I was first prompted with companyID, then, Forms![MainFormName]![List1Name].

Am I missing some required components (like library) for Access 2003?

Again thanks.


:

You can link the rowsource of list2 to the selection of list1

Select productID, productName
From product
Where companyID = Forms![MainFormName]![List1Name]

On the after update event of list 1, you need to refresh list2 by adding the
code in the code section

me.list2.requery


:

Hi,

I'm new to Access Form and I've asked a similar question without meaningful
result, ENV: Access 2003. Here I'll give it another shot.

The question is, I have a form, say, field A shows a list of companies, its
data is generated by a query like
Select companyID, companName
From company
then, upon selection of a particular company,
field B would display a list of products provided by this company, so, the
query would look like this:
Select productID, productName
From product
Where companyID = {thePreviouslySelectedCompanyID}

It should be fairly simple. How can I accomplish the above?

Thanks a bunch in advance.
 
I

ImJoe

How about copying everything from the subform to the main form then disable
connection between the two? Does that make sense? If so, how to do it?


Ofer said:
What is the name of the form, and the name of the field?
When you run the query, the form should be open.


ImJoe said:
I certainly did not copy and paste your sample code. What could cause the
problem?
fyi, the Access 2003 was not intalled by me.

Ofer said:
Dont write the SQL as I gave you, change it to suit your details

Select productID, productName
From product
Where companyID = Forms![MainFormName]![List1Name]

MainFormName= The name of your form
List1Name = the name of the list within the form
companyID = The Company Id Field name in the table


:

Thank you very much. I've have been fumbling with it for the last forty
minutes or so trying different things, however, to no avail.

Testing of the following query also failed with Access 2003 (first prompted
from companyID then produced no records)
Select productID, productName
From product
Where companyID = Forms![MainFormName]![List1Name]

However, the above query behaved differently with Access 97,
I was first prompted with companyID, then, Forms![MainFormName]![List1Name].

Am I missing some required components (like library) for Access 2003?

Again thanks.


:

You can link the rowsource of list2 to the selection of list1

Select productID, productName
From product
Where companyID = Forms![MainFormName]![List1Name]

On the after update event of list 1, you need to refresh list2 by adding the
code in the code section

me.list2.requery


:

Hi,

I'm new to Access Form and I've asked a similar question without meaningful
result, ENV: Access 2003. Here I'll give it another shot.

The question is, I have a form, say, field A shows a list of companies, its
data is generated by a query like
Select companyID, companName
From company
then, upon selection of a particular company,
field B would display a list of products provided by this company, so, the
query would look like this:
Select productID, productName
From product
Where companyID = {thePreviouslySelectedCompanyID}

It should be fairly simple. How can I accomplish the above?

Thanks a bunch in advance.
 
Top