B
Bob Vanderslice
I have a form with a ComboBox that I want to automatically insert a value
into another field. Basically, I'm pulling from a table that has two
fields....when I choose "FieldA" I want "FieldB" to automatically populate.
I've done this before, but always when there were not multiple occurrences
of FieldA. Trouble is, this time there are many of FieldA......FieldB is
unique within FieldA. Such as:
Project1......Task1
Project1......Task2
Project1......Task3
Project1......Task4
Project1......Task5
Project2......Task1
Project2......Task2
Project2......Task3
Project3......Task1
Project3......Task2
Currently, I'm using the following.....but when I select a given Project, it
will then only select the first TaskNo for that Project. How do I get it to
select the specific one I want to choose.....for example, Project1...Task4
instead of Project1....Task1?
Thanks,
Bob
Private Sub Combo32_BeforeUpdate(Cancel As Integer)
Dim db As Database
Dim rst As Recordset
Set db = CurrentDb
Set rst = db.OpenRecordset("tblProject-TaskNo", dbOpenDynaset)
rst.FindFirst "Proj = " & Chr(34) & Me.Combo32.Value & Chr(34)
If Not rst.NoMatch Then
Me.task_number.Value = rst!TaskNo
End If
rst.Close
Set db = Nothing
End Sub
into another field. Basically, I'm pulling from a table that has two
fields....when I choose "FieldA" I want "FieldB" to automatically populate.
I've done this before, but always when there were not multiple occurrences
of FieldA. Trouble is, this time there are many of FieldA......FieldB is
unique within FieldA. Such as:
Project1......Task1
Project1......Task2
Project1......Task3
Project1......Task4
Project1......Task5
Project2......Task1
Project2......Task2
Project2......Task3
Project3......Task1
Project3......Task2
Currently, I'm using the following.....but when I select a given Project, it
will then only select the first TaskNo for that Project. How do I get it to
select the specific one I want to choose.....for example, Project1...Task4
instead of Project1....Task1?
Thanks,
Bob
Private Sub Combo32_BeforeUpdate(Cancel As Integer)
Dim db As Database
Dim rst As Recordset
Set db = CurrentDb
Set rst = db.OpenRecordset("tblProject-TaskNo", dbOpenDynaset)
rst.FindFirst "Proj = " & Chr(34) & Me.Combo32.Value & Chr(34)
If Not rst.NoMatch Then
Me.task_number.Value = rst!TaskNo
End If
rst.Close
Set db = Nothing
End Sub