unloading a form at load time
-
Dim checkSQL As String checkSQL = "SELECT OrderGenerate.OrderNumber, Client.Company, OrderGenerate.Completed " & _ " FROM Client INNER JOIN OrderGenerate ON Client.ClientCode = OrderGenerate.ClientCode " & _ " WHERE OrderGenerate.OrderDate= #" & dDate & "#" Set RS = Conn.Execute(checkSQL) If RS.BOF And RS.EOF Then MsgBox "No orders yet today", vbExclamation, "No records returned" Unload Me Exit Sub End If The above is code that is located at the form load of the form. if no records are returned from the SQL statement, i wish the message box to be displayed and the form to be unloaded, however on run time, it crashes "object was unloaded" - is there anything i can do to fix this? any help would be greatly appreciated!
-
Dim checkSQL As String checkSQL = "SELECT OrderGenerate.OrderNumber, Client.Company, OrderGenerate.Completed " & _ " FROM Client INNER JOIN OrderGenerate ON Client.ClientCode = OrderGenerate.ClientCode " & _ " WHERE OrderGenerate.OrderDate= #" & dDate & "#" Set RS = Conn.Execute(checkSQL) If RS.BOF And RS.EOF Then MsgBox "No orders yet today", vbExclamation, "No records returned" Unload Me Exit Sub End If The above is code that is located at the form load of the form. if no records are returned from the SQL statement, i wish the message box to be displayed and the form to be unloaded, however on run time, it crashes "object was unloaded" - is there anything i can do to fix this? any help would be greatly appreciated!
try this and let me know :)
If RS.BOF And RS.EOF Then MsgBox "No orders yet today", vbExclamation, "No records returned" Conn.Close rs.Close Set Conn=Nothing Set rs=Nothing Unload Me Exit Sub End If