access 2007 - vba - forms collection

  • Thread starter Alain Bourgeois
  • Start date

A

Alain Bourgeois

Chers tous,

j'ai écrit la fonction suivante pour changer la propriété filterOnLoad
de chaque formulaire de la db.

*************************
Function correctAccess2007()

Dim Ff As Form, i As Integer

i = 0

For Each Ff In Forms
i = i + 1
DoCmd.OpenForm Ff.Name, acDesign
Ff.FilterOnLoad = False
DoCmd.Close acForm, Ff.Name, acSaveYes
Next
MsgBox "forms:" & i
End Function
**********************
quand j'exécute sous access2007, il affiche "0".
Si j'utilise le même code pour modifier une propriété existant en access
2000/2002/2003 (filter, backColor, ...) ca marche!

La collection Forms n'existe plus en 2007????? (mais il ne donne pas
d'erreur quand on l'utilise)

Merci,
Alain
 
Ad

Advertisements

G

George Nicholson

Forms collection = open forms (excluding subforms)
AllForms collection = all Forms in database

Dim obj As AccessObject
Dim dbs As Object

Set dbs = Application.CurrentProject
For Each obj In dbs.AllForms
i = i + 1
DoCmd.OpenForm obj.Name, acDesign
........

HTH,
 
P

Pieter Wijnen

Dim Cont As DAO.Container
Dim Doc As DAO.Document

Dim Ff As Access.Form
Dim i As Integer

Set Cont = Access.CurrentDb.Containers("Forms")
i = 0
For Each Doc In Cont.Documents
DoCmd.OpenForm Doc.Name, acDesign
Set Ff = Access.Forms(Doc.Name)
i = i + 1
Ff.FilterOn = False
DoCmd.Close acForm, Doc.Name, acSaveYes

Next 'Doc

HTH

Pieter
 
A

Alain Bourgeois

Cont.Documents est invalide...

Pieter said:
Dim Cont As DAO.Container
Dim Doc As DAO.Document

Dim Ff As Access.Form
Dim i As Integer

Set Cont = Access.CurrentDb.Containers("Forms")
i = 0
For Each Doc In Cont.Documents
DoCmd.OpenForm Doc.Name, acDesign
Set Ff = Access.Forms(Doc.Name)
i = i + 1
Ff.FilterOn = False
DoCmd.Close acForm, Doc.Name, acSaveYes

Next 'Doc

HTH

Pieter
 
Ad

Advertisements

A

Alain Bourgeois

ok, merci, j'ai pris le meilleur des deux posts: ca marche.

Dim ff1 As Access.Form
Dim i As Integer
Dim ff As AccessObject
Dim dbs As Object

Set dbs = Application.CurrentProject

For Each ff In dbs.AllForms
DoCmd.OpenForm ff.Name, acDesign
Set ff1 = Access.Forms(ff.Name)
i = i + 1
If ff1.FilterOnLoad Then ff1.FilterOnLoad = False
DoCmd.Close acForm, ff.Name, acSaveYes
Next 'Doc


MsgBox "forms:" & i
 

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