Re: Cannot save Form changes with VBA



Labels are controls with static captions, such as: "Name" and "DOB".
Textboxes are often associated with labels and in them we can be enter
or modify data like "Larry Linson" and "1909-04-01". TextBoxes may
have default values.
If the form and textbox are bound to a field in a table then the
changes made to the textbox are likely to be saved in that field in
that table and to appear next time we open the Form and navigate to
the record.

But there is nothing inherent or implicit in a form which permits the
saving of data entered into a textbox. If we open the form in design
mode and change the caption of a label or the default value of a
textbox and save the form then the new caption or default value will
be saved with the form.

I think neither a bound form, nor changes in the form's design is what
you want to do.

This may effect what you want to do (for a control named "ExcelPath"):

Private Sub Form_Load()
On Error Resume Next
ExcelPath.Value = _
CurrentProject.AllForms(Me.Name).Properties("DefaultExcelPath").Value
End Sub


Private Sub Form_Unload(Cancel As Integer)
With CurrentProject.AllForms(Me.Name).Properties
.Add "DefaultExcelPath", ExcelPath.Value
.Item("DefaultExcelPath").Value = ExcelPath.Value
End With
End Sub

Of course, there will be no default value saved until the second time
the form is opened.


On May 31, 8:45 am, "KC-Mass" <connearneyATcomcastDOTnet> wrote:
I have a form that is used to ID and then load Excel files into Access.
I use labels on the form to record which file was last loaded.  That was
accomplished with a simple lblFileLoaded = strFullFileName.  The label
would show the file name and when the form was closed and then opened
it would still show the name of the last file loaded. That preserves an
important piece of information.

Suddenly the form has stopped doing that.  When you close the form and
reopen it the lbl is blank or has the name from the second prior session.

At someone's suggestion I tried to Save the form on exit. with
"DoCmd.Save acForm, "frmLoad".  It gives an error msg of
"the object "frmLoad" is not loaded.  The form is loaded and the
following test routine, found on the web,  confirms that it is loaded.

Sub test()
  Dim IsOpen As Boolean
  IsOpen = adhIsFormOpen("frmLoad")
  Debug.Print IsOpen

End Sub
Public Function adhIsFormOpen(strname As String) As Boolean
    On Error Resume Next
    Dim FIsOpen As Boolean
    FIsOpen = CurrentProject.AllForms(strname).IsLoaded
    adhIsFormOpen = (Err.Number = 0) And FIsOpen
    Err.Clear
End Function

Anyway I really need to have these labels saved on exit

Any ideas?

Thx
Kevin

.



Relevant Pages

  • Re: Cannot save Form changes with VBA
    ... If the form and textbox are bound to a field in a table then the ... Private Sub Form_Load ... I use labels on the form to record which file was last loaded. ... Public Function adhIsFormOpenAs Boolean ...
    (comp.databases.ms-access)
  • Re: cant load a textbox array at runtime
    ... Private WithEvents mTB As TextBox ... Friend Sub Init(ParentArr As cTBArray, ...   Set mParentArr = ParentArr ... Public Property Get TBAs TextBox ...
    (microsoft.public.vb.general.discussion)
  • Re: Maintaining Macros on a sheet when it is saved as a new workbook
    ... There is more than one type of TextBox. ... workwook is displayed together with the sheet name and sub. ... the macro to open the TextBox works, but the macro to close it does ...     Cancel = True ...
    (microsoft.public.excel.programming)
  • Re: Urgent.. prob w/ Datagrid edit button
    ... My code within the datagrid describes the buttons: ... Private Sub dgTimber_UpdateCommand(ByVal source As Object, ... Basically what I want is when I hit the edit button a textbox ...    End Function ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: How do I access ComboBox.SelectedText from another thread?
    ...     Public Delegate Sub DelegateUIUpdate(ByVal dgv As DataGridView, ... Sub CallsByScriptWorker() ... ECCValue ELSE NULL END) AS ExternalID, ... values of the other controls like the datetimechooser and textbox. ...
    (microsoft.public.dotnet.languages.vb)