473,473 Members | 1,985 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Cannot save Form changes with VBA

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
May 31 '08 #1
2 4012
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("Defau ltExcelPath").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" <connearneyATcomcastDOTnetwrote:
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
May 31 '08 #2
Thanks very much.

The form is unbound so I am not looking to fill text boxes with the data
as that would not preserve the data. I could certainly tie it all to a
table but
label.captions seemed an easy way to hold the few pieces of data.

I just now got the form to save using the reference me.name vice a literal,
"frmLoad". Got that style of reference from your code below.

Thanks again.
"lyle fairfield" <ly************@gmail.comwrote in message
news:8d**********************************@x35g2000 hsb.googlegroups.com...
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("Defau ltExcelPath").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" <connearneyATcomcastDOTnetwrote:
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

May 31 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Christopher Brandsdal | last post by:
Hi! I get an error when I run my code Is there any other way to get te information from my form? Heres the error I get and the code beneath. Line 120 is market with ''''''''''''Line...
2
by: icedgar | last post by:
am using the following script in the BeforeUpdate area of a main form. Private Sub Form_BeforeUpdate(Cancel As Integer) Dim strMsg As String strMsg = "Do you wish to save your changes?" If...
6
by: Aaron Smith | last post by:
Ok. I have a dataset that has multiple tables in it. In one of the child tables, I have a column that I added to the DataSet (Not in the DataSource). This column does not need to be stored in the...
8
by: dbuchanan | last post by:
Hello, What does this error mean? "The event click is read-only and cannot be changed" This is a design-time error. It is displayed instead of the form. Here is the full text \\ "One or...
0
by: Patty05 | last post by:
I have a datagrid on a form that update properly when form loads. When the program runs and I type in/add a new row in the datagrid, it does not save the changes. Any help would be greatly...
2
by: rockdc1981 | last post by:
I dont it is possible to put this codes together.. I want to prompt the user to save the record and at the same time have a log of audit trail. the codes work out fine separately. Code for Audit...
6
by: subhashkumar | last post by:
Running data Append to a table Dear All, I need a help from this forum, I was developing a small tools for stock market. I get stuck when trying to save the running changes in a data field...
2
by: Matuag | last post by:
Hi All, I want to create following command buttons on a Form which users can edit. Save ( Save Changes made) Cancel ( Undo data changes) Exit ( Close form) I am using Macros for each of...
2
by: KC-Mass | last post by:
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 =...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.