J
jim
Hi all, a pop-up form is opened from a subform with this code:
Private Sub Form_Open(Cancel As Integer)
Dim strCustomerName As String
Dim strBuildingNo As Long
If IsNull(OpenArgs) = False Then
Dim arrArgs() As String
arrArgs = Split(Me.OpenArgs, "~")
strCustomerName = arrArgs(0)
strBuildingNo = arrArgs(1)
End If
End Sub
It is working good and my array, arrArgs, is populating strCustomerName and
strBuildingNo perfectly. If a new record is needed I use the following:
Private Sub Form_BeforeUpdate(Cancel As Integer)
'Me!txtCustomerName.Value = Me!txtCustomerName.DefaultValue
'Me!CustomerName.Value =
Forms("sfrmClientBuildContacts").Controls("txtCustomerName").Value
' Me!BuildingNo.Value =
Forms("sfrmClientBuildContacts").Controls("txtBuildingNo").Value
If NewRecord Then 'When a new contact
is added assign next Contact Number for Building
If DCount("ContactNo", "tblClientBuildContacts", "[CustomerName]
= """ & Me![CustomerName] & """ AND [BuildingNo] = " & Me![BuildingNo]) = 0
Then
Me.txtContactNo = 1
Else
Me.txtContactNo = DMax("ContactNo", "tblCustomerContacts",
"[CustomerName] = """ & txtCustomerName & """ AND [BuildingNo] = " &
txtBuildingNo) + 1
End If
End If
End Sub
As you can see I've tried several things I've found in the discussion group
but Me.CustomerName and Me.BuildingNo is always blank. How do I use the
values that were captured is the first Open subroutine?
TIA
Private Sub Form_Open(Cancel As Integer)
Dim strCustomerName As String
Dim strBuildingNo As Long
If IsNull(OpenArgs) = False Then
Dim arrArgs() As String
arrArgs = Split(Me.OpenArgs, "~")
strCustomerName = arrArgs(0)
strBuildingNo = arrArgs(1)
End If
End Sub
It is working good and my array, arrArgs, is populating strCustomerName and
strBuildingNo perfectly. If a new record is needed I use the following:
Private Sub Form_BeforeUpdate(Cancel As Integer)
'Me!txtCustomerName.Value = Me!txtCustomerName.DefaultValue
'Me!CustomerName.Value =
Forms("sfrmClientBuildContacts").Controls("txtCustomerName").Value
' Me!BuildingNo.Value =
Forms("sfrmClientBuildContacts").Controls("txtBuildingNo").Value
If NewRecord Then 'When a new contact
is added assign next Contact Number for Building
If DCount("ContactNo", "tblClientBuildContacts", "[CustomerName]
= """ & Me![CustomerName] & """ AND [BuildingNo] = " & Me![BuildingNo]) = 0
Then
Me.txtContactNo = 1
Else
Me.txtContactNo = DMax("ContactNo", "tblCustomerContacts",
"[CustomerName] = """ & txtCustomerName & """ AND [BuildingNo] = " &
txtBuildingNo) + 1
End If
End If
End Sub
As you can see I've tried several things I've found in the discussion group
but Me.CustomerName and Me.BuildingNo is always blank. How do I use the
values that were captured is the first Open subroutine?
TIA