Hello
I am using Access 2k and have a form with roughly 50 combo boxes. They are in 3 columns as each column represents a time slot and each row is an equipment set. The combos will pull down with a list of employee names. It's basically a rotation schedule for work.
Anyway I would like some validation to prevent an emps name from appearing more than once in a column. I thought a loop for each column would be a good start. For now I just want to make sure each cbo is filled in.
Using the control loop I have...
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
For i = 1 to 20
If IsNullMe.Controls("CboEmp" & i) Then
MsgBox "Fill in selections."
End If
Next i
End Sub
...but the msgbox never comes up whether the combos are filled or not.
Maybe beforeUpdate is the wrong method to put this under.
I also tried it within a save routine but I get the error message "Object required"
if there is an entry or not in the combobox.
Code:
Private Sub cmdSaveRecord_Click()
On Error GoTo Err_cmdSaveRecord_Click
For i = 1 To 20
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
If IsNullMe.Controls("CboEmp" & i) Then
MsgBox "Fill in selections."
End If
Next i
Exit_cmdSaveRecord_Click:
Exit Sub
Err_cmdSaveRecord_Click:
MsgBox Err.Description
Resume Exit_cmdSaveRecord_Click
End Sub
Have a great safe weekend!
Hal
I am using Access 2k and have a form with roughly 50 combo boxes. They are in 3 columns as each column represents a time slot and each row is an equipment set. The combos will pull down with a list of employee names. It's basically a rotation schedule for work.
Anyway I would like some validation to prevent an emps name from appearing more than once in a column. I thought a loop for each column would be a good start. For now I just want to make sure each cbo is filled in.
Using the control loop I have...
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
For i = 1 to 20
If IsNullMe.Controls("CboEmp" & i) Then
MsgBox "Fill in selections."
End If
Next i
End Sub
...but the msgbox never comes up whether the combos are filled or not.
Maybe beforeUpdate is the wrong method to put this under.
I also tried it within a save routine but I get the error message "Object required"
if there is an entry or not in the combobox.
Code:
Private Sub cmdSaveRecord_Click()
On Error GoTo Err_cmdSaveRecord_Click
For i = 1 To 20
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
If IsNullMe.Controls("CboEmp" & i) Then
MsgBox "Fill in selections."
End If
Next i
Exit_cmdSaveRecord_Click:
Exit Sub
Err_cmdSaveRecord_Click:
MsgBox Err.Description
Resume Exit_cmdSaveRecord_Click
End Sub
Have a great safe weekend!
Hal