Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form Closes When Switching from Datasheet to Form View

Status
Not open for further replies.

poppysdad

Programmer
Jun 8, 2007
4
US
I developed an Access application about three years ago and it's worked fine. I converted to 2007 with no issues. I am in the process of moving from an Access backend to a MOSS 3.0 Custom List backend.

All has gone very well. All of my vba code still executes. I have run into one odd problem, though.

I present the user with a form containing a list of firms and addresses in datasheet view . I have a button which switches from datasheet to form view in order to display detail information about a specific vendor. This has worked flawlessly (and still works when connected to an Access backend). When changing from datasheet to form view and back the form doesn't close, it just changes views.

Now, when executing code which changes between datasheet and form views, the datasheet closes, then re-opens in form view. The issue is that it fires the OnClose and OnOpen events and causes problems. This does not happen when programmatically moving from form to datasheet view, though.

I use the following code to move between the two modes:

===== Code Starts =======

Private Sub butShowForm_Click()

'Code used to switch from datasheet to form view and back

If butShowForm.Value = False Then

' If form is currently in Datasheet view, change button caption and change to Form view

butShowForm.Caption = "Show Datasheet"
DoCmd.OpenForm "frmVendors", acNormal

Else

' If form is currently in Form view, change button caption and change to Datasheet view

butShowForm.Caption = "Show Details"
DoCmd.OpenForm "frmVendors", acFormDS

End If

End Sub

===== Code Ends =====

I realize that OpenForm by implication could close the form before opening in a different view, but, as I said earlier, this action only occurs when connected to a SharePoint backend and when switching from datasheet to form view. I suppose I could determine the form state in the butShowForm code and work from there, but that wouldn't solve the On... events issue. In addition, the code is stable and I really don't want to muck about with it.

Thanks for your help.

Alan Miller
 
One point I left off. If the DB is opened in read-only mode, this doesn't happen. Only when the DB is able to write to the backend does this happen.

Sorry about the omission...

Alan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top