In the AfterUpdate I also had code setting the value to
Null for the second and third combo boxes. That is what
was causing the error, however after I remove this code I
am receiving a different error. The combo boxes do update
themselves to the current customer account, but if the I
selected a customer account 1897 which as in combo box 2
Job codes 1 - 24 and in combo box 3 Steps 1-7 ; then if I
change the customer account combo 1 to 3537 which has job
codes 1-7 and steps combo 3 for that... If I originally
had the job 22 selected from the first customer, the new
account 3537 doesn't have that job number and if I attempt
to save the record I get an error saying that the value I
am trying to set is invalid and I am asked to debug the
code. However if I do change the second and third combo I
can save the records correctly. I am posting all of the
code and I hope my explaination of the problem is
solvable....
Private Sub cmbCust_Acct_AfterUpdate()
Me.cmbJob_No.Requery
Me.cmbStep_No.Requery
End Sub
Private Sub cmbCust_Acct_NotInList(NewData As String,
Response As Integer)
strMsg = "You have entered an Customer Account Number
that does not exist " & _
"insure you have the entered the correct Customer
Account Number " & _
"if the Customer Account Number is correct and not
available on this list " & _
"you will need to add them to the Customer Table"
strTitle = "Invalid Customer Account Number"
intStyle = vbOKOnly
MsgBox strMsg, intStyle, strTitle
Me.cmbCust_Acct.SetFocus
Response = acDataErrContinue
End Sub
Private Sub cmbEmployeeID_NotInList(NewData As String,
Response As Integer)
strMsg = "You have entered an Employee ID that does
not exist " & _
"insure you have the entered the correct Employee
ID " & _
"if the Employee ID is correct and not available
on this list " & _
"you will need to add them to the Client Table"
strTitle = "Invalid Employee ID"
intStyle = vbOKOnly
MsgBox strMsg, intStyle, strTitle
Me.cmbEmployeeID.SetFocus
Response = acDataErrContinue
End Sub
Private Sub cmbJob_No_AfterUpdate()
Me.cmbStep_No.Requery
End Sub
Private Sub cmbJob_No_NotInList(NewData As String,
Response As Integer)
strMsg = "You have entered an Job Number that does not
exist " & _
"insure you have the entered the correct Job
Number " & _
"if the Job Number is correct and not available on
this list " & _
"you will need to add the Job to the Rate Table"
strTitle = "Invalid Job Number"
intStyle = vbOKOnly
MsgBox strMsg, intStyle, strTitle
Me.cmbJob_No.SetFocus
Response = acDataErrContinue
End Sub
Private Sub Form_BeforeUpdate(Cancel As Integer)
' Checks to make sure that all required fields do not
have Null Values
Dim strMsg As String
Dim bWarn As Boolean
Dim strField As String
If IsNull(Me.cmbEmployeeID) = True Or Me!cmbEmployeeID
= "" Then
Cancel = True
strMsg = strMsg & "Employee ID Required." & vbCrLf
strField = "cmbEmployeeID"
Else
Me.CENTER_NO = Me.CLIENTsubform.Form!CENTER_NO
Me.DEPT_NO = Me.CLIENTsubform.Form!DEPT_NO
End If
If IsNull(Me.cmbCust_Acct) = True Or Me!cmbCust_Acct
= "" Then
Cancel = True
strMsg = strMsg & "Customer Account Number
Required." & vbCrLf
strField = "cmbCust_Acct"
End If
If IsNull(Me.cmbJob_No) = True Or Me!cmbJob_No = ""
Then
Cancel = True
strMsg = strMsg & "Job Number Required." & vbCrLf
strField = "cmbJob_no"
End If
If IsNull(Me.cmbStep_No) = True Or Me!cmbStep_No = ""
Then
Cancel = True
strMsg = strMsg & "Step Number Required." & vbCrLf
strField = "cmbStep_No"
Else
Me.JOB_CODE = Me.RATETABL_subform1.Form!JOB_CODE
End If
If IsNull(Me.DATEPERFMD) = True Or Me!DATEPERFMD = ""
Then
Cancel = True
strMsg = strMsg & "Date Performed Required." &
vbCrLf
strField = "dateperfmd"
End If
If IsNull(Me.[Start Time]) = True Or Me![Start Time]
= "" Then
Cancel = True
strMsg = strMsg & "Start Time Required." & vbCrLf
strField = "[Start Time]"
End If
If IsNull(Me.[Stop Time]) = True Or Me![Stop Time]
= "" Then
Cancel = True
strMsg = strMsg & "Stop Time Required." & vbCrLf
strField = "[Stop Time]"
Else
Me.TOTALHOURS = Me.TotalTime1
End If
If IsNull(Me.NO_ACCEPTD) = True Or Me!NO_ACCEPTD = ""
Then
Cancel = True
strMsg = strMsg & "Number of Accepted Units
Required." & vbCrLf
strField = "No_Acceptd"
Else
Me.PIECERATE = Me.RATETABL_subform1.Form!PIECERATE
Me.PRVL_RATE = Me.RATETABL_subform1.Form!PRVL_RATE
Me.AMT_EARN = (Me.NO_ACCEPTD - Me.NO_REJECTD) *
Me.PIECERATE
End If
If IsNull(Me.NO_REJECTD) = True Or Me!NO_REJECTD = ""
Then
Cancel = True
strMsg = strMsg & "Number of Rejected Units
Required." & vbCrLf
strField = "NO_REJECTD"
End If
If Cancel Then
strMsg = strMsg & "Enter the data, or Press <Esc>
to undo."
MsgBox strMsg, , "Invalid data"
Else
'Do your warnings.
If IsNull(Me.cmbEmployeeID) = True Or Me!
cmbEmployeeID = "" Then
bWarn = True
strMsg = strMsg & "Employee ID Required." &
vbCrLf
strField = "cmbEmployeeID"
End If
If IsNull(Me.cmbCust_Acct) = True Or Me!
cmbCust_Acct = "" Then
bWarn = True
strMsg = strMsg & "Customer Account Required."
& vbCrLf
strField = "cmbCust_Acct"
End If
If bWarn Then
strMsg = strMsg & vbCrLf & "Proceed anyway?"
If MsgBox(strMsg, vbYesNo +
vbDefaultButton2, "Warning") <> vbYes Then
Cancel = True
End If
End If
End If
'Set focus to the problem field.
If Cancel And Len(strField) > 0 Then
Me(strField).SetFocus
End If
End Sub
Private Sub Form_Open(Cancel As Integer)
Me.cmbEmployeeID.SetFocus
End Sub
Private Sub btnSaveRecord_Click()
On Error GoTo Err_btnSaveRecord_Click
DoCmd.DoMenuItem acFormBar, acRecordsMenu,
acSaveRecord, , acMenuVer70
Exit_btnSaveRecord_Click:
Exit Sub
Err_btnSaveRecord_Click:
MsgBox Err.Description
Resume Exit_btnSaveRecord_Click
End Sub
-----Original Message-----
message news:
[email protected]
That doesn't make sense to me. Why should requerying the combo boxes
force your form to attempt to save the record? You didn't slip up and
write "Me.Requery" when you meant to
write "Me.ComboBoxName.Requery",