Hi All,
A pleasure to be a new member of this forum; prior programming experience, but relatively new to VBA so I apologise in advance if my questions appear neophytic.
This should hopefully be an easy one:
As part of an existing if/elseif block, I'm look to test whether a table contains valid records, and, at the same time, assign the number of valid records in such table to a local variable.
Currently my code uses the following structure:
A number of criteria are tested, but I must then use a nested if statement in order to store a count of the number of valid records before testing it.
Therefore, is there a way to do the following?:
Thank you in advance for your time.
A pleasure to be a new member of this forum; prior programming experience, but relatively new to VBA so I apologise in advance if my questions appear neophytic.
This should hopefully be an easy one:
As part of an existing if/elseif block, I'm look to test whether a table contains valid records, and, at the same time, assign the number of valid records in such table to a local variable.
Currently my code uses the following structure:
Code:
Sub test()
Dim cnt As Long
if < ... > then
MsgBox "< ... > Invalid"
elseif < ... > then
MsgBox "< ... > Invalid"
elseif < ... > then
MsgBox "< ... > Invalid"
Else
cnt = DCount("Item", "Table", "Item <> ' '")
If cnt = 0 Then
MsgBox "No valid records found."
End If
End If
End Sub
Therefore, is there a way to do the following?:
Code:
Sub test()
Dim cnt As Long
if < ... > then
MsgBox "< ... > Invalid"
elseif < ... > then
MsgBox "< ... > Invalid"
elseif < ... > then
MsgBox "< ... > Invalid"
ElseIf (cnt = DCount("Item", "Table", "Item <> ' '")) = 0 Then
MsgBox "No valid records found."
End If
End Sub