detect form opening by tabular form or datasheet form

T

thecuongjapan

Hi,
Is there a way to detect form opening in tabular form or datasheet form (by
using On open event of that form)?
thanks
 
6

'69 Camaro

Hi.
Is there a way to detect form opening in tabular form or datasheet form (by
using On open event of that form)?

Yes. Try:

Private Sub Form_Open(Cancel As Integer)

On Error GoTo ErrHandler

Select Case Me.CurrentView
Case acCurViewDatasheet
MsgBox "In datasheet view."
Case Else
MsgBox "Not in datasheet view."
End Select

Exit Sub

ErrHandler:

MsgBox "Error in Form_Open( ) in " & vbCrLf & Me.Name & _
" form." & vbCrLf & vbCrLf & "Error #" & _
Err.Number & vbCrLf & Err.Description
Err.Clear

End Sub

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips and tutorials.
http://www.Access.QBuilt.com/html/expert_contributors2.html for contact info.

- - -
If my answer has helped you, please sign in and answer yes to the question
"Did this post answer your question?" at the bottom of the message, which
adds your question and the answers to the database of answers. Remember that
questions answered the quickest are often from those who have a history of
rewarding the contributors who have taken the time to answer questions
correctly.
 
T

thecuongjapan

many Thanks for your reply

'69 Camaro said:
Hi.


Yes. Try:

Private Sub Form_Open(Cancel As Integer)

On Error GoTo ErrHandler

Select Case Me.CurrentView
Case acCurViewDatasheet
MsgBox "In datasheet view."
Case Else
MsgBox "Not in datasheet view."
End Select

Exit Sub

ErrHandler:

MsgBox "Error in Form_Open( ) in " & vbCrLf & Me.Name & _
" form." & vbCrLf & vbCrLf & "Error #" & _
Err.Number & vbCrLf & Err.Description
Err.Clear

End Sub

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips and tutorials.
http://www.Access.QBuilt.com/html/expert_contributors2.html for contact info.

- - -
If my answer has helped you, please sign in and answer yes to the question
"Did this post answer your question?" at the bottom of the message, which
adds your question and the answers to the database of answers. Remember that
questions answered the quickest are often from those who have a history of
rewarding the contributors who have taken the time to answer questions
correctly.
 
Top