I have a ton of queries that I need users to be able to view. I'd like to
have them viewed in a datasheet-view form instead of directly, so that I can
keep the users from futzing with the data.
I'd like to do this in a temporary database, creating an autoform based on
the query and making that form the source object for a subform in a
pre-existing main form. I just ran a quick-and-dirty test, using the code at
the bottom of this post, and it seems to work reasonably well (the client
doesn't have much money to spend, so reasonably well is good enough, or will
be once I tweak the code and nudge the main form).
I'm using Call DoCmd.RunCommand(acCmdNewObjectAutoForm) to create the form.
It works fine, as long as I've got the query highlighted in the database
window. Is there a way to supply a query name for this wizard? Or is there a
way to control what's highlighted in the database window?
Many thanks for any pointers.
Jeremy
--
Sub MakeTheForm()
Call DoCmd.DeleteObject(acForm, "Form1")
Call DoCmd.RunCommand(acCmdNewObjectAutoForm)
Call DoCmd.Save
Forms!form1.AllowEdits = False
Forms!form1.AllowAdditions = False
Forms!form1.AllowDeletions = False
Call DoCmd.OpenForm("form1", acDesign)
Forms!form1.DefaultView = 2 'datasheet
Call DoCmd.Save
Call DoCmd.Close(acForm, "Form1")
Call DoCmd.OpenForm("frmTempMain")
Forms!frmMain.SetFocus
End Sub
=================
Jeremy Wallace
AlphaBet City Dataworks
ABCDataworks dot com