Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Populate subform based on 2 fields

Status
Not open for further replies.

jmhicsupt

MIS
Oct 22, 2005
49
0
0
US
I have a main form and a subform. I need to populate a field based on the value of two other fields – one field resides in the main form and one field resides in the subform.

Mainform field: SaleType
Subform field: ProductType
Field to be populated (resides in the Subform): OrderNumber

Here’s the criteria:

If Mainform.SaleType = Existing
And if subform.ProductType = “Apples”
The subform.OrderNumber = “red”

What is the code for this and where would I put the code?

Thanks in advance.
 
You can place this code in Subform
Event : OrderNumber_AfterUpdate

Code:
Private Sub OrderNumber_AfterUpdate()
   If IsNull([Forms]!Mainform.SaleType)=True Then
      msgbox "Please Select SaleType"
      Exit Sub
   End If

   If IsNull(Me.ProductType)=True Then
      msgbox "Please Select ProductType"
      Exit Sub
   End If

   If [Forms]!Mainform.SaleType = Existing And Me.ProductType = “Apples” Then
       me.OrderNumber = “red”
   End If
End Sub

Regards,
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top