I have a database that contains code that sets the DefaultView property of a form to 'Datasheet'. Apparently in order to do this, it is required that the form be opened in Design View, so my code opens the form in Design View and sets the DefaultView Property. I then have code that closes the form and saves the settings and then re-opens the form (in normal view) so that something can be done in it.
The problem is that when the code re-opens the form, the form opens in Single Form view. However, it appears that the code did actually change the DefaultView, because if I rem out the code that opens the form in normal view (after the design view changes) and manually open the form, the view is Datasheet.
So, there appears to be something about opening the form manually that must somehow refresh the datatabase with the changes that opening it from code doesn't do. Is there a way in code to refresh the database so it applies the change?
Any assistance is appreciated..here is the code:
Public Sub mkqry_open_se_term_tbl()
'makes a query to open the term se table so that only certain fields are displayed for user choice..
Dim d As Database
Dim frm As Form
Dim qdf As QueryDef
Dim str_sql As String
Dim frm2 As Form
Set frm = Forms!frm_pr_proc_sel_req
str_sql = "select * from " & str_tbl_name_se_term
str_qry_name_se_term = frm.cbo_assoc_id & Now()
Set d = CurrentDb
Set qdf = d.CreateQueryDef(str_qry_name_se_term, str_sql)
DoCmd.OpenForm "frm_term_se", acDesign
Set frm2 = Forms!frm_term_se
frm2.RecordSource = str_qry_name_se_term 'set recordsource of form
frm2.DefaultView = 2
DoCmd.OpenForm "frm_term_se", acNormal
DoCmd.Close acForm, "frm_term_se", acSaveYes
DoCmd.OpenForm "frm_term_se", acNormal