code worked in 2003 but not in 2007 version

M

Ms.Re-WA

With your help last summer, I put in the following codes and it worked
beautifully. This year I have Access 2007 instead of Access 2003 on my
computer and they are not working.

In this one, two notices should appear if this is a new record. Neither
appears when I begin a new record.

Private Sub Form_Current()
If Me.NewRecord = True Then
Me.NoAnswer.Visible = True
Me.Label48.Visible = True
End If
End Sub

This should auto fill the School and Text_used fields based on the
information in the Teachers table for a new record. Nothing happens.

Private Sub Teacher_AfterUpdate()
If Me.NewRecord Then
Me.School = DLookup("[School]", "Teachers", "[Teacher id] = " &
Me.Teacher)
Me.Text_Used = DLookup("[Text Used]", "Teachers", "[Teacher id] = " &
Me.Teacher)
End If
End Sub

As I put in the answers in the subform that the students gave on the test,
this code is supposed to increment the number in the Question id column,
which then looks up the day and question number from the Questions table.
What happens now is it fills in a "1" in the Question ID column every time.
The look up part seems to work if I manually enter the Question ID.


Private Sub Form_BeforeInsert(Cancel As Integer)
Dim IngQNbr As Long
If Me.NewRecord Then
IngQNbr = Me.Parent![Student number]
IngQNbr = Nz(DMax("[Question id]", "Test Data", "[Student id] = " &
IngQNbr), 0) + 1

If IngQNbr > DMax("[Question id]", "Questions") Then
MsgBox "No More Questions"
Cancel = True
Me.Undo
Else
Me.Question_id = IngQNbr
End If
End If

It seems that all are related to the New Record command. Has something
changed in Access 2007 that has made my code ineffectual?

Thanks for any help.

Ms. Re
 
A

Allen Browne

As none of the code works, I'm guessing that you need to let A2007 know you
trust the folder where you database resides.

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)
 
M

Ms.Re-WA

I did as you suggested and at first it did nothing. Then I noticed a warning
about some content being disabled. After I said to enable, it all worked!
Will I have to enable it every time I open the file? Or will this trust
setting I did take care of it?

Thanks for your help so quickly! (You must be a night owl, too!)

Ms. Re
 
M

Ms.Re-WA

Thank you very much. I know it seemed simple to you, but it is a big relief
to me and the school district that this is for.

Ms. Re
 
L

LindaSD

I have just moved to 2007 and all my 60 some 2003 databases have vb and
marcos that are not working. I have done as told for the trust center
settings and still cannot get OnClick and AfterUpdate vb simple code to run.
Wondering if this solved your problem - did the trust center information you
got here end your issues? Thanks - Linda
 
A

Allen Browne

Suggestions to get one database running:

1. Create a folder in the root of C: drive, e.g. C:\Data.

2. Make a copy of your database there.

3. Open My Computer to the folder where office is installed, e.g.:
C:\Program Files\Microsoft Office\Office12
Right-drag msaccess.exe from this folder to your desktop, and choose:
Create Shortcut.

4. If using Windows Vista, right-click this shortcut, and in its Properties,
check the box for:
Run As Administrator.

5. Use this shortcut to open Access. Go to the trust center, and tell it you
trust the folder you created at step 1.

6. Open the database. Open the Immediate Window (Ctrl+G.) Choose References
on the Tools menu, and fix any problems you see there. More info on
references:
http://allenbrowne.com/ser-38.html

7. Still in the code window, choose Compile on the Debug menu.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top