detect form opening by tabular form or datasheet form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
Is there a way to detect form opening in tabular form or datasheet form (by
using On open event of that form)?
thanks
 
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.
 
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top