Option Compare Database
Private Sub cboAreaID_AfterUpdate()
If Me.cboRespPartyID = 1 Or Me.cboRespPartyID = 8 Or Me.cboRespPartyID = 12 Then
PlantofOrigin = DLookup("Area", "tblArea", "AreaID=" & Forms!frmComplaints.cboAreaID)
Else
PlantofOrigin = "N/A"
End If
End Sub
Private Sub cboAreaID_Change()
Me.cboLocationID.Requery
End Sub
Private Sub cboComplaintCatID_Change()
Me.cboComplaintTypeID.Requery
End Sub
Private Sub cboProdCatID_Change()
Me.cboProdCodeID.Requery
End Sub
Private Sub cboProdCatID_Dirty(Cancel As Integer)
Me.cboProdCodeID.Requery
End Sub
Private Sub cboProductID_Change()
Me.cboRespPartyID.Requery
Me.cboAreaID.Requery
Me.cboLocationID.Requery
Me.cboProdCatID.Requery
Me.cboProdCodeID.Requery
End Sub
Private Sub cboRespPartyID_Change()
Me.cboAreaID.Requery
Me.cboLocationID.Requery
End Sub
Private Sub cmdCancel_Click()
'Set counter table back one if this is a new entry
If strUsertype = "New" Then
'Save record first, so if new, the RptNum will be captured for deletion & resetting counter table
DoCmd.RunCommand acCmdSaveRecord
'Run query to set counter back
DoCmd.SetWarnings False
DoCmd.OpenQuery ("qryUPCounterforCancel")
'Now, delete the record
DoCmd.SetWarnings False
DoCmd.RunCommand acCmdDeleteRecord
DoCmd.SetWarnings True
'If user is not new, do nothing, just undo changes
Else
If Me.Dirty = True Then
Me.Undo
End If
End If
DoCmd.Close
End Sub
Private Sub cmdMADMOrder_Click()
Me.ADMOrder.SetFocus
Me.ADMOrder.Text = "Multiple"
End Sub
Private Sub cmdMCarLotTr_Click()
Me.CarLotTrailerNum.SetFocus
Me.CarLotTrailerNum.Text = "Multiple"
End Sub
Private Sub cmdMCarrier_Click()
Me.Carrier.SetFocus
Me.Carrier.Text = "Multiple"
End Sub
Private Sub cmdMCarrier_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Me.lblButtonHelp.Visible = True
End Sub
Private Sub Form_Current()
'Refesh all comboboxes
Me.cboProductID.Requery
Me.cboRespPartyID.Requery
Me.cboAreaID.Requery
Me.cboLocationID.Requery
Me.cboComplaintCatID.Requery
Me.cboComplaintTypeID.Requery
Me.cboProdCatID.Requery
Me.cboProdCodeID.Requery
End Sub
Private Sub Form_Load()
If strUsertype = "New" Then
'Take form out of Data Cntry mode
Me.DataEntry = True
Me.AllowAdditions = True
Dim CurrentYear
Dim CounterYear
Dim LastCounterNum
Dim NewComplaintNum As String
CurrentYear = Right(Date, 2)
CounterYear = DLookup("Year", "ComplaintsCounterTable")
CounterYear = Right(CounterYear, 2)
LastCounterNum = DLookup("LastCounterNum", "ComplaintsCounterTable")
DoCmd.SetWarnings False
If CurrentYear - CounterYear = 1 Then
'Reset the table for the new year and first complaint --run an update query to reset the value
DoCmd.OpenQuery ("qryUPResetCounterforNewYear")
Else
'add one to last counter and use year for CurrrentYear variable --Use update query for first part
DoCmd.OpenQuery ("qryUPCountertoNextComplaintNum")
End If
DoCmd.SetWarnings True
NewComplaintNum = LastCounterNum + 1 & "-" & CurrentYear
Me.ComplaintNum = NewComplaintNum
Me.AllowAdditions = False
Me.EntryDateTimeStamp = Now()
Me.CustomerName.SetFocus
ElseIf strUsertype = "Response" Then
Me.DataEntry = False
Me.AllowAdditions = False
Me.lblButtonHelp.Visible = False
Me.cmdClose.SetFocus
LockForm
End If
End Sub
Public Sub LockForm()
Dim ctl As Control
Dim strName As String
Dim strTag As String
For Each ctl In Me.Controls
If (ctl.ControlType = acTextBox Or ctl.ControlType = acComboBox Or ctl.ControlType = acCheckBox Or ctl.ControlType = acOptionButton) And ctl.Tag = "lock" Then
strName = ctl.Name
ctl.Enabled = False
ctl.Locked = True
ElseIf ctl.ControlType = acCommandButton And ctl.Tag = "lock" Then
ctl.Enabled = False
End If
Next ctl
End Sub