Hi All,
New here!
Hoping someone can help me. I'm self taught in VBA and this issue has stumped me.
I have a table "tblMtemp" there is a column for "PackNum"
What I'm trying to do is right some code that verifies that for "PackNum" there is at least one Checkbox checked.
In this example, 6788881 has at least one check box select (True) so this okay.
But pack 6788882 has no checkboxes select, this isn't okay.
I'm attempting to use a DLookup but I'm new to using them and that doesn't help when trying to figure out this logic.
Currently my code only seems to look at the top record. I can't do a look because then it wants to apply everything per record rather than by the range of PackNum
Here is the code I'm working with currently
Any help would be very greatly appreciated!
Thanks!
-Deke
New here!
Hoping someone can help me. I'm self taught in VBA and this issue has stumped me.
I have a table "tblMtemp" there is a column for "PackNum"
What I'm trying to do is right some code that verifies that for "PackNum" there is at least one Checkbox checked.
In this example, 6788881 has at least one check box select (True) so this okay.
But pack 6788882 has no checkboxes select, this isn't okay.
I'm attempting to use a DLookup but I'm new to using them and that doesn't help when trying to figure out this logic.
Currently my code only seems to look at the top record. I can't do a look because then it wants to apply everything per record rather than by the range of PackNum
Here is the code I'm working with currently
Code:
Private Sub Okay_Button_Click()
Dim db As DAO.Database
Dim rs2 As DAO.Recordset
Dim strPack As String
Set db = CurrentDb
Set rs2 = CurrentDb.OpenRecordset("tblMtemp")
strPack = rs2.Fields("PackNum").Value
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Data Validation check that there is at least one box checks for each packnumber
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
If IsNull(DLookup("PackNum", "tblMtemp", rs2.Fields("PackNum") = " & strPack & ")) Then
If DLookup("[PackNum]", "tblMtemp", rs2.Fields("Select") = False) Then
Else
MsgBox "Please select at least one offer for Pack Number " & rs2.Fields("PackNum") & ""
Exit Sub
End If
End If
End Sub
Any help would be very greatly appreciated!
Thanks!
-Deke