I have a command button on a form to add a task
Private Sub AddTaskBttn_Click()
Dim Result As String
Dim Sn As String
Sn = Me.cmbDSerialNumber.Column(0)
DoCmd.SetWarnings False
DoCmd.RunSQL "Insert Into Tasklist( TSerialNumber ) Select '" & Sn & "' As Expr;"
Result = DLookup("[TSerialNumber]", "TaskList", "[TSerialNumber]='" & Sn & "' ")
DoCmd.OpenForm "Task", acNormal, , "TaskList.TSerialNumber" = Sn, acFormAdd, acDialog, Sn
DoCmd.SetWarnings True
End Sub
On the task form I have the following procedure
Private Sub Form_Load()
If Not IsNull(Me.OpenArgs) Then
' If form's OpenArgs property has a value, assign the contents
' of OpenArgs to the CompanyName field. OpenArgs will contain
' a company name if this form is opened using the OpenForm
' method with an OpenArgs argument, as done in the Orders
' form's CustomerID_NotInList event procedure.
Sn = Me.OpenArgs
Sn = Me![TSerialNumber]
Me![TSerialNumber] = Me.OpenArgs
Me.Requery
End If
End Sub
A new record is being inserted with the proper Tserialnumber but the rest of the fields are blank. These fields are on the task form. However when
the record on the task form is saved the Tserialnumber is blank. In the immediate window it seems that sn still holds a value when the form is opened.
Any help would greatly be appreciated.
Private Sub AddTaskBttn_Click()
Dim Result As String
Dim Sn As String
Sn = Me.cmbDSerialNumber.Column(0)
DoCmd.SetWarnings False
DoCmd.RunSQL "Insert Into Tasklist( TSerialNumber ) Select '" & Sn & "' As Expr;"
Result = DLookup("[TSerialNumber]", "TaskList", "[TSerialNumber]='" & Sn & "' ")
DoCmd.OpenForm "Task", acNormal, , "TaskList.TSerialNumber" = Sn, acFormAdd, acDialog, Sn
DoCmd.SetWarnings True
End Sub
On the task form I have the following procedure
Private Sub Form_Load()
If Not IsNull(Me.OpenArgs) Then
' If form's OpenArgs property has a value, assign the contents
' of OpenArgs to the CompanyName field. OpenArgs will contain
' a company name if this form is opened using the OpenForm
' method with an OpenArgs argument, as done in the Orders
' form's CustomerID_NotInList event procedure.
Sn = Me.OpenArgs
Sn = Me![TSerialNumber]
Me![TSerialNumber] = Me.OpenArgs
Me.Requery
End If
End Sub
A new record is being inserted with the proper Tserialnumber but the rest of the fields are blank. These fields are on the task form. However when
the record on the task form is saved the Tserialnumber is blank. In the immediate window it seems that sn still holds a value when the form is opened.
Any help would greatly be appreciated.