Hi Folks,
I am finalizing a program I have written by creating some error controls/warning messages. The code below doesn't want to work ... I think I am doing something stupid, but can't seem to find out how to get it to work. I have used the exact same code without the DoCmd.RunSQL and instead with other error tests such as comparing stuff in text boxes and what not and it has worked perfectly, so I think it is something I am doing wrong with passing the result of the SQL to the variable? In essance, the code checks to see if any lines exist in a table ... if no lines exist in a table, a message box is returned stating that. Any help would be appreciated.
Private Sub Command39_Click()
Dim countoflines As Integer
If DoCmd.RunSQL("select count(*) from MyTableName") = 0 Then
MsgBox ("You do not have anything to create a table from")
GoTo done
End If
done: MsgBox ("Your table has records in it")
End Sub
I am finalizing a program I have written by creating some error controls/warning messages. The code below doesn't want to work ... I think I am doing something stupid, but can't seem to find out how to get it to work. I have used the exact same code without the DoCmd.RunSQL and instead with other error tests such as comparing stuff in text boxes and what not and it has worked perfectly, so I think it is something I am doing wrong with passing the result of the SQL to the variable? In essance, the code checks to see if any lines exist in a table ... if no lines exist in a table, a message box is returned stating that. Any help would be appreciated.
Private Sub Command39_Click()
Dim countoflines As Integer
If DoCmd.RunSQL("select count(*) from MyTableName") = 0 Then
MsgBox ("You do not have anything to create a table from")
GoTo done
End If
done: MsgBox ("Your table has records in it")
End Sub