By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,630 Members | 1,010 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,630 IT Pros & Developers. It's quick & easy.

data in a tex field on an unbound form

P: n/a
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

Dec 26 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a

<je*********@snclavalin.com> wrote in message
news:11*********************@o13g2000cwo.googlegro ups.com...
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


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.

--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com
Dec 26 '05 #2

P: n/a
je*********@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)
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


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.
--
Lyle Fairfield
Dec 26 '05 #3

P: n/a
Does this value need to be available after the entire application (mdb file)
has been closed and re-opened, or just during one session?

<je*********@snclavalin.com> wrote in message
news:11*********************@o13g2000cwo.googlegro ups.com...
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

Dec 26 '05 #4

P: n/a
Ted
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

je*********@snclavalin.com wrote:
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


Dec 27 '05 #5

P: n/a
The value need to be available after the entire mdb file is close and
reopen again

thanks

Dec 27 '05 #6

P: n/a
<je*********@snclavalin.com> wrote in message
news:11********************@g44g2000cwa.googlegrou ps.com...
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.

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

Dec 27 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.