Update cbx2 based on selection in cbx1

S

spacerocket

How do I update cbx2 based on what user selected in cbx1? I tried with this
code in the Row Source of cbx2, but the list box only displayed 1 selection
instead of all selections available based on selected value in cbx1:

SELECT Project.ProjectID, Project.ProjectName FROM Project WHERE
Project.ProjectID=Forms!F_Transaction_Records!CompanyID ORDER BY
[ProjectName];

Thanks a lot.
 
S

spacerocket

Thanks, now it works.

I have another question. When I open the form and scroll through the
records, cbx1 and cbx2 does not contain any data. The data for cbx2 is
recorded in table1.field2, but cbx1 is unbound. Perhaps the requery doesn't
work for existing records since there is no AfterUpdate event? Therefore I
created a new field, table1.field1 to store data for cbx1. I opened the form
but the both cbx is still empty.

How do I show to current data for both cbx1 and cbx2 in Edit Form mode?
Thanks again.



Ofer said:
You might need to refresh the data in Combo2 After updating combo1.
How do I update cbx2 based on what user selected in cbx1? I tried with this
code in the Row Source of cbx2, but the list box only displayed 1 selection
instead of all selections available based on selected value in cbx1:

SELECT Project.ProjectID, Project.ProjectName FROM Project WHERE
Project.ProjectID=Forms!F_Transaction_Records!CompanyID ORDER BY
[ProjectName];

Thanks a lot.
 
S

spacerocket

I tried this code but it doesn't work. Appreciate any help I can get. Thanks.

Private Sub Form_Open(Cancel As Integer)

If Me.OpenArgs = "GotoNew" And Not IsNull(Me![TransactionID]) Then
Me.BankName.Requery
Me.ProjectName.Requery
Me.CompanyName.Requery
Me.PaymentMethod.Requery
Me.ChequeNumber.Requery
Me.Amount.Requery
End If

End Sub

spacerocket said:
Thanks, now it works.

I have another question. When I open the form and scroll through the
records, cbx1 and cbx2 does not contain any data. The data for cbx2 is
recorded in table1.field2, but cbx1 is unbound. Perhaps the requery doesn't
work for existing records since there is no AfterUpdate event? Therefore I
created a new field, table1.field1 to store data for cbx1. I opened the form
but the both cbx is still empty.

How do I show to current data for both cbx1 and cbx2 in Edit Form mode?
Thanks again.



Ofer said:
You might need to refresh the data in Combo2 After updating combo1.
How do I update cbx2 based on what user selected in cbx1? I tried with this
code in the Row Source of cbx2, but the list box only displayed 1 selection
instead of all selections available based on selected value in cbx1:

SELECT Project.ProjectID, Project.ProjectName FROM Project WHERE
Project.ProjectID=Forms!F_Transaction_Records!CompanyID ORDER BY
[ProjectName];

Thanks a lot.
 
O

Ofer

If you move between records, you need to put the me.Combo2Name.requery on the
OnCurrent event of the form

spacerocket said:
I tried this code but it doesn't work. Appreciate any help I can get. Thanks.

Private Sub Form_Open(Cancel As Integer)

If Me.OpenArgs = "GotoNew" And Not IsNull(Me![TransactionID]) Then
Me.BankName.Requery
Me.ProjectName.Requery
Me.CompanyName.Requery
Me.PaymentMethod.Requery
Me.ChequeNumber.Requery
Me.Amount.Requery
End If

End Sub

spacerocket said:
Thanks, now it works.

I have another question. When I open the form and scroll through the
records, cbx1 and cbx2 does not contain any data. The data for cbx2 is
recorded in table1.field2, but cbx1 is unbound. Perhaps the requery doesn't
work for existing records since there is no AfterUpdate event? Therefore I
created a new field, table1.field1 to store data for cbx1. I opened the form
but the both cbx is still empty.

How do I show to current data for both cbx1 and cbx2 in Edit Form mode?
Thanks again.



Ofer said:
You might need to refresh the data in Combo2 After updating combo1.
On the after update event of combo1 write the code
Me.Combo2Name.requery


:

How do I update cbx2 based on what user selected in cbx1? I tried with this
code in the Row Source of cbx2, but the list box only displayed 1 selection
instead of all selections available based on selected value in cbx1:

SELECT Project.ProjectID, Project.ProjectName FROM Project WHERE
Project.ProjectID=Forms!F_Transaction_Records!CompanyID ORDER BY
[ProjectName];

Thanks a lot.
 
S

spacerocket

The requery doesn't work on my code even after I've put the requery in the
OnCurrent event :(

This is the code in my form (the selection in combobox TransactionType will
affect the ctrl source for other comboboxes):

---------
Private Sub TransactionType_AfterUpdate()

If Me![TransactionType] = "Income" Then
Me.PaymentMethod.ControlSource = "PaymentMethod_Received"
Me.ChequeNumber.ControlSource = "ChequeNumber_Received"
Me.Amount.ControlSource = "Amount_Received"
Else
Me.PaymentMethod.ControlSource = "PaymentMethod_Paid"
Me.ChequeNumber.ControlSource = "ChequeNumber_Paid"
Me.Amount.ControlSource = "Amount_Paid"
End If

Me![PaymentMethod].Requery
Me![ChequeNumber].Requery
Me![Amount].Requery

End Sub
---------

My requery code:

Private Sub Form_Current()

Me.PaymentMethod.Requery
Me.ChequeNumber.Requery
Me.Amount.Requery

End Sub
---------

Really appreciate your help, thanks a lot.

Ofer said:
If you move between records, you need to put the me.Combo2Name.requery on the
OnCurrent event of the form

spacerocket said:
I tried this code but it doesn't work. Appreciate any help I can get. Thanks.

Private Sub Form_Open(Cancel As Integer)

If Me.OpenArgs = "GotoNew" And Not IsNull(Me![TransactionID]) Then
Me.BankName.Requery
Me.ProjectName.Requery
Me.CompanyName.Requery
Me.PaymentMethod.Requery
Me.ChequeNumber.Requery
Me.Amount.Requery
End If

End Sub

spacerocket said:
Thanks, now it works.

I have another question. When I open the form and scroll through the
records, cbx1 and cbx2 does not contain any data. The data for cbx2 is
recorded in table1.field2, but cbx1 is unbound. Perhaps the requery doesn't
work for existing records since there is no AfterUpdate event? Therefore I
created a new field, table1.field1 to store data for cbx1. I opened the form
but the both cbx is still empty.

How do I show to current data for both cbx1 and cbx2 in Edit Form mode?
Thanks again.



:

You might need to refresh the data in Combo2 After updating combo1.
On the after update event of combo1 write the code
Me.Combo2Name.requery


:

How do I update cbx2 based on what user selected in cbx1? I tried with this
code in the Row Source of cbx2, but the list box only displayed 1 selection
instead of all selections available based on selected value in cbx1:

SELECT Project.ProjectID, Project.ProjectName FROM Project WHERE
Project.ProjectID=Forms!F_Transaction_Records!CompanyID ORDER BY
[ProjectName];

Thanks a lot.
 
Top