Hello:
I have a form (Default view =single form) with a subform (Default view =continuous forms) embedded into it. In the form I have three controls that display the Division, Working Region & Credit Region. The subform displays the data/records. The record source for both my form and subform is driven by a query, which is the way I filter the records that the end user will see via another form I created.
Everything is working fine but I can not seem to figure something out that I have never done before.
The issue is that the end user can add a new record via my subform. My challenge is that one of the fields that is displayed is called “Product” There are a lot of products to choose from on this drop down list but not as many if the list was filtered by Working Region. The layout of my product table is as follows:
Product:
tblProduct
ProductID = Autonumber
ProductsName = Text
WrkRegID = Number (This is for my one to many relationship; a working region can have many different Products)
Is there a way to filter the list of my product field on my subform for new records?
I was trying to experiment with doing this and can not figure it out. What I did get to work was on the header of my subform I dropped in a combo box and then on the load event of that form wrote the following code:
[code=vb]
Private Sub Form_Load()
'When the Working Region has been displayed on the form, the appropriate Product list
'will display in the drop down list of CboProduct
With Me![cboProduct]
If IsNull(Me!txtWr kReg) Then
.RowSource = ""
Else
.RowSource = "SELECT [ProductsName] FROM tblProduct WHERE [WrkRegID]=" & _
DLookup("[WrkRegID]", "tblWrkRegi on", "[WrkRegionName] = '" & Me![txtWrkReg] & "'")
End If
Call .Requery
End With
End Sub
[/code]
As mentioned this worked. The problem is that the minute I embedded that control “cboProduct” in the detail portion of my subform I do not get any errors, the list will be appropriately populated but if let’s say three records are displaying, the minute I make a selection from cboProduct all of the records will be change to that selection. I only want it to change new records not the old ones.
Does anybody have any idea on how this can be done??
Thanks,
Keith.
I have a form (Default view =single form) with a subform (Default view =continuous forms) embedded into it. In the form I have three controls that display the Division, Working Region & Credit Region. The subform displays the data/records. The record source for both my form and subform is driven by a query, which is the way I filter the records that the end user will see via another form I created.
Everything is working fine but I can not seem to figure something out that I have never done before.
The issue is that the end user can add a new record via my subform. My challenge is that one of the fields that is displayed is called “Product” There are a lot of products to choose from on this drop down list but not as many if the list was filtered by Working Region. The layout of my product table is as follows:
Product:
tblProduct
ProductID = Autonumber
ProductsName = Text
WrkRegID = Number (This is for my one to many relationship; a working region can have many different Products)
Is there a way to filter the list of my product field on my subform for new records?
I was trying to experiment with doing this and can not figure it out. What I did get to work was on the header of my subform I dropped in a combo box and then on the load event of that form wrote the following code:
[code=vb]
Private Sub Form_Load()
'When the Working Region has been displayed on the form, the appropriate Product list
'will display in the drop down list of CboProduct
With Me![cboProduct]
If IsNull(Me!txtWr kReg) Then
.RowSource = ""
Else
.RowSource = "SELECT [ProductsName] FROM tblProduct WHERE [WrkRegID]=" & _
DLookup("[WrkRegID]", "tblWrkRegi on", "[WrkRegionName] = '" & Me![txtWrkReg] & "'")
End If
Call .Requery
End With
End Sub
[/code]
As mentioned this worked. The problem is that the minute I embedded that control “cboProduct” in the detail portion of my subform I do not get any errors, the list will be appropriately populated but if let’s say three records are displaying, the minute I make a selection from cboProduct all of the records will be change to that selection. I only want it to change new records not the old ones.
Does anybody have any idea on how this can be done??
Thanks,
Keith.
Comment