it is possible? if the user in the running time, click the close button or the X button that we can see in the top of the form and then if the user click the close or X button message box will appear "you cannot log out"? how can i do this? thanks. .

Recommended Answers

All 4 Replies

why not set the "borderstyle" properties of the form to "0-None" so the form will not display "X" the user will not be able to terminate your program unless user choose to close the program using "task manager"

it is possible? if the user in the running time, click the close button or the X button that we can see in the top of the form and then if the user click the close or X button message box will appear "you cannot log out"? how can i do this? thanks. .

yes this is possible

Private Sub Form_Unload(Cancel As Integer)
Cancel = True 'set to any none zero number could be cancel=1
MsgBox "Running, cannot close form now!"
End Sub

hi thanks for your code but i have a problem

Set rs = New ADODB.Recordset
rs.Open "Select * from temp", cn, adOpenKeyset, adLockPessimistic
If Val(rs!quantity) = Null Then
calcel = False
Unload Me
Else
cancel = True
MsgBox "You Must Purchase it First, Before Log out", vbInformation
lvButtons_H3.SetFocus
End If

either bof or eof is true? that is the error. .

Well that is an entirely different animal. Try adding an if statement to check for the existance of a valid recordset...

If rs.BOF = False AND rs.EOF = False AND rs.RowCount <> 0 Then
  'we have a valid recordset with at least one record
End If
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.