Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 1 / December 2005

Tip: Looking for answers? Try searching our database.

data in a tex field on an unbound form

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
jean.ulrich@snclavalin.com - 26 Dec 2005 15:49 GMT
Hi
I have a form that is not related with a table neither a query (unbound
form)

On this form I have a text field where the user can put a text or a
number

As I dont want to create a table just for that field, is it possible
that when someone write someting in the field, the text don't disapear
when he close the form and open it again

I was thinking about something like this

on form close text in the box become the default value

thanks
Rick Brandt - 26 Dec 2005 16:02 GMT
> Hi
> I have a form that is not related with a table neither a query (unbound
[quoted text clipped - 10 lines]
>
> on form close text in the box become the default value

That would require that you open the form in design view.  Setting the
DefaultValue property on an open form is not persisted between uses of the form.

There is nothing you could do that would be easier than just using a table.

Signature

I don't check the Email account attached
to this message.     Send instead to...
RBrandt    at       Hunter      dot      com

Lyle Fairfield - 26 Dec 2005 17:13 GMT
jean.ulrich@snclavalin.com wrote in news:1135612171.381152.91350
@o13g2000cwo.googlegroups.com:

> I have a form that is not related with a table neither a query (unbound
> form)
[quoted text clipped - 5 lines]
> I was thinking about something like this
> on form close text in the box become the default value

This is air code but it should work if you are using Access 2000 or
later.

Private Sub Form_Close()
   On Error GoTo Text0err:
   Text0.SetFocus
   CurrentProject.AllForms(Me.Name).Properties("Text0").Value = _
   Nz(Me.Text0.Value, "")
   Exit Sub

Text0err:
   CurrentProject.AllForms(Me.Name).Properties.Add "Text0", _
   Nz(Me.Text0.Value, "")
   Resume Next
End Sub

Private Sub Form_Open(Cancel As Integer)
   On Error Resume Next
   Text0.Value = _
   CurrentProject.AllForms(Me.Name).Properties("Text0").Value
End Sub

There may be extra line breaks introduced by the usenet clients. These
will have to be removed.

Signature

Lyle Fairfield

MacDermott - 26 Dec 2005 18:12 GMT
Does this value need to be available after the entire application (mdb file)
has been closed and re-opened, or just during one session?

> Hi
> I have a form that is not related with a table neither a query (unbound
[quoted text clipped - 12 lines]
>
> thanks
jean.ulrich@snclavalin.com - 27 Dec 2005 07:37 GMT
The value need to be available after the entire mdb file is close and
reopen again

thanks
Randy Harris - 27 Dec 2005 14:02 GMT
> The value need to be available after the entire mdb file is close and
> reopen again
>
> thanks

In that case, you should store the data in a table.  In several applications
that I've developed I have a table called preferences.  This allows users to
change program settings and have the settings remain from session to
session.  It works extremely well.

Signature

Randy Harris
tech at promail dot com
I'm pretty sure I know everything that I can remember.

Ted - 27 Dec 2005 00:19 GMT
What about saving the value in the Windows Registry, then retrieving it
when you need it?
Here are some code samples for saving, retrieving and deleting registry
entries you create using VBA in Access: (I can't remember where I found
these commands, but they are sure handy!)

Registry Settings Using VBA

1)This first command doesn't access the registry but checks to see what
the title of the application is. If you don't have one, go into the
Tools, Options menu and add an Application Title:
   MsgBox CurrentDb.Properties("AppTitle")

Note: Let's says the name of your application is: Access Pro.

2) This entry saves the current date into the Registry as:
HKEY_CURRENT_USER/Software/VB and VBA Program Settings/Access
Pro/Settings/Date =12/26/2005:

   SaveSetting CurrentDb.Properties("AppTitle"), "Settings", "Date",
Format(Now(), "mm/dd/yyyy")

3) This entry saves the current date into the Registry as:
HKEY_CURRENT_USER/Software/VB and VBA Program Settings/Access
Pro/Settings/Author =Ted Palsson:
   SaveSetting CurrentDb.Properties("AppTitle"), "Settings", "Author",
"Ted Palsson"

4) This command retrieves the Date from the above listed date key and
displays it:
   MsgBox GetSetting(CurrentDb.Properties("AppTitle"), "Settings",
"Date")

5) This command retrieves and displays the name of the application
Author from the listed Author key:
   MsgBox GetSetting(CurrentDb.Properties("AppTitle"), "Settings",
"Author")

6) This command deletes the specified Registry Key titled Date:
   DeleteSetting CurrentDb.Properties("AppTitle"), "Settings" ',
"Date"

Hope this will help you (or anyone else who may want to save values in
the Windows Registry.
Another suggested use is:
  - Store the value of the last record displayed so you can reopen the
form with a filter to display the last record viewed. Example:
   Dim stDocName As String
   Dim stLinkCriteria As String
   stDocName = "fmContacts"
   stLinkCriteria = "[ContactID]=" &
GetSetting(CurrentDb.Properties("AppTitle"), "Settings",
"LastContactID")
   DoCmd.OpenForm stDocName, , , stLinkCriteria

When you close the form, have it save the value of the current
ContactID in the registry. I always create a Close button which closes
the form when I click on it. In the OnClick event property for the
button, add code similar to the following before the code that closes
the form:
    SaveSetting CurrentDb.Properties("AppTitle"), "Settings",
"LastContactID", Me.ContactID

NOTE: Since this effects the Current User key value, the settings will
vary for each user if you have more than one user who "logs on" to the
same computer.

Ted

> Hi
> I have a form that is not related with a table neither a query (unbound
[quoted text clipped - 12 lines]
>
> thanks
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.