jesus_hairdo
Registered User.
- Local time
- Today, 11:24
- Joined
- Sep 28, 2001
- Messages
- 32
I have 2 combo boxes on a form,
when a value from box 1 (called Combo68) is selected this changes the values in box2 (called Combo70). (or more correctly changes the source sql script).
using this code,
-----------------
Private Sub Combo68_AfterUpdate()
Me.Combo70.RowSourceType = "Table/Query"
Me.Combo70.RowSource = "SELECT [tbl_category_complaint_type].[complaint_type] FROM [tbl_category_complaint_type] where [tbl_category_complaint_type].[category] = '" & Me.Combo68.Value & "';"
End Sub
--------------
This works fine on a new record, but when i go to an existing record box2 (combo70) shows the correct field value, BUT the combo box list shows the entries from the last new record.
I tried using this code
-----------------
Private Sub Combo70_BeforeUpdate(Cancel As Integer)
If IfEmpty(Me.Combo68.Value) Then
Me.Combo70.RowSourceType = "Value List"
Me.Combo70.RowSource = "Select Category first"
Else
Me.Combo70.RowSourceType = "Table/Query"
Me.Combo70.RowSource = "SELECT [tbl_category_complaint_type].[complaint_type] FROM [tbl_category_complaint_type] where [tbl_category_complaint_type].[category] = '" & Me.Combo68.Value & "';"
End If
End Sub
------------------------
However, all that happens is that the combo box2 (combo70) lists "select category first" regardless of whether the 1st combo box(combo68) has a value or not if no new/updated records have been entered. If a new/updated record has been entered it shows that records' values.
The Basic idea being that when entering a new record combo70 just reads "Select category first" (combo68), then when i select a value in combo68, combo70's values change.
if its an existing record with a value of combo68 it just uses that and selects the correct values
any ideas ??
cheers
when a value from box 1 (called Combo68) is selected this changes the values in box2 (called Combo70). (or more correctly changes the source sql script).
using this code,
-----------------
Private Sub Combo68_AfterUpdate()
Me.Combo70.RowSourceType = "Table/Query"
Me.Combo70.RowSource = "SELECT [tbl_category_complaint_type].[complaint_type] FROM [tbl_category_complaint_type] where [tbl_category_complaint_type].[category] = '" & Me.Combo68.Value & "';"
End Sub
--------------
This works fine on a new record, but when i go to an existing record box2 (combo70) shows the correct field value, BUT the combo box list shows the entries from the last new record.
I tried using this code
-----------------
Private Sub Combo70_BeforeUpdate(Cancel As Integer)
If IfEmpty(Me.Combo68.Value) Then
Me.Combo70.RowSourceType = "Value List"
Me.Combo70.RowSource = "Select Category first"
Else
Me.Combo70.RowSourceType = "Table/Query"
Me.Combo70.RowSource = "SELECT [tbl_category_complaint_type].[complaint_type] FROM [tbl_category_complaint_type] where [tbl_category_complaint_type].[category] = '" & Me.Combo68.Value & "';"
End If
End Sub
------------------------
However, all that happens is that the combo box2 (combo70) lists "select category first" regardless of whether the 1st combo box(combo68) has a value or not if no new/updated records have been entered. If a new/updated record has been entered it shows that records' values.
The Basic idea being that when entering a new record combo70 just reads "Select category first" (combo68), then when i select a value in combo68, combo70's values change.
if its an existing record with a value of combo68 it just uses that and selects the correct values
any ideas ??
cheers