I simply cannot get this code to function. I have a form all unbound text boxes and am using coding to transfer the data entered to my main data table. It simply is not working, not sure why. Code posted below, used option explicit for a spelling safeguard. Any help appreciated, thanks.
Code:
Sub cmdSubmit_Click()
On Error GoTo Err_proc0
If IsNull(Me.cboCell) Or IsNull(Me.txtDowntime) Or IsNull(Me.txtRamp) Or IsNull(Me.txtDetail) Or IsNull(Me.txtCause) Or IsNull(Me.txtPart) Then
MsgBox "Some key field(s) are empty. Please completely fill form before submission."
End If
Exit Sub
Dim DE As Object
Dim PI As Object
Set DE = CurrentDb.OpenRecordset("tbl_DataEntry")
Set PI = CurrentDb.OpenRecordset("tbl_PartsInfo")
' Add data records to respective tables
DE.AddNew
PI.AddNew
DE![Cell_Product_FK] = Me.cboCell.Value
DE![ProductType_FK] = Me.txtProduct.Value
DE![EntryDate] = Me.txtDate.Value
DE![Details] = Me.txtDetail.Value
DE![RootCause] = Me.txtCause.Value
DE![Downtime] = Me.txtDowntime.Value
DE![RampUp] = Me.txtRamp.Value
DE![LaborIncrs] = Me.txtLabor.Value
DE![PartNumber_FK] = Me.txtPart.Value
If Me.txtPart = DLookup("PartNumber_PK", "tbl_PartsInfo", "PartNumber_PK =" & Forms![frm_Entry]!txtPart) Then
MsgBox "Please leave the Description box blank for this submission."
Else:
DE![Description] = Me.txtDscrp.Value
PI![PartNumber_PK] = Me.txtPart.Value
End If
DE.Update
PI.Update
Set DE = Nothing
Set PI = Nothing
Exit Sub
Err_proc0:
MsgBox Err.Description
Exit Sub
End Sub