code works in 2000, won't work in 2007

A

Angie

I am really quite new to this. I found a bit of code in these forums that
allowed me to get data entered in a form to remain in the text boxes after
you started a new record. This was wonderful, and just what we needed.
Problems arose when someone tried to use this form in Access 2007. The text
box was blank when you started a new record, where as in 2000 it carries the
data over.

Here's an example of the code I used:

Sub TAGR_AfterUpdate()
With Me.TAGR
..DefaultValue = Chr(34) & .Value & Chr(34)
End With
End Sub

Is there something I need to alter to get it to work in both 2000 and 2007?
Any help would be greatly appreciated.
 
L

Linq Adams via AccessMonster.com

Does any code work inn 2007? Code does not run in 2007 unless your database
resides in a folder that has been declared a “trusted†location.

To trust your folder, click:

Office Button (top left)
Access Options (bottom of dialog)
Trust Center (left)
Trust Center Settings (button)
Trusted Locations (left)
Add new location (button)
 
A

Angie

TAGR is the name of the text box in the form, not the database its self. The
form has about 30 data entry points, only about 5 or so that need to have
data carried from one record to the next.

And thank you very much, when my boss gets back I'll have her set the folder
to trusted!
 
L

Linq Adams via AccessMonster.com

That may be the answer, but I asked the question about the datatype (in this
case it would be the datatype of the field the TAGR textbox was bound to)
because the exact syntax varies, depending on whether the datatype is text,
numeric or date/time.The general syntaxes are

For Date fields

Private Sub YourDateControlName_AfterUpdate()
If Not IsNull(Me.YourDateControlName.Value) Then
YourDateControlName.DefaultValue ="#" & Me.YourDateControlName & "#"
End If
End Sub

For Text fields

Private Sub YourTextControlName_AfterUpdate()
If Not IsNull(Me.YourTextControlName.Value) Then
YourTextControlName.DefaultValue = """" & Me.YourTextControlName.Value &
""""
End If
End Sub

For Numeric fields

Private Sub YourNumericControlName_AfterUpdate()
If Not IsNull(Me.YourNumericControlName.Value) Then
YourNumericControlName.DefaultValue = Me.YourNumericControlName.Value
End If
End Sub

You can, of course, replace the aingle/double quote marks with Chr(34) and so
forth.
 
Top