Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Modifying proprieties of ctrls in multiple forms

Status
Not open for further replies.

mfh1984

Programmer
Oct 29, 2001
2
DE
Hello,

I wrote few lines of code under Access 2000 to alter proprieties of controls in all a database. My pbl is on the 95th form, I get this error : The operation or action 'OpenForm' is not available right now. Anyone have more idea than me ?


For Each anAccessObj In appAccess.CurrentProject.AllForms
If anAccessObj.Type = acForm Then
appAccess.DoCmd.OpenForm anAccessObj.Name, acDesign
For Each aCtrl In appAccess.Forms(anAccessObj.Name).Controls
If aCtrl.Properties("ControlType").Value = 109 Then
If ToEuro Then
If aCtrl.Properties("Format").Value = "Currency" Then
aCtrl.Properties("Format").Value = "Euro"
End If
Else
If aCtrl.Properties("Format").Value = "Euro" Then
aCtrl.Properties("Format").Value = "Currency"
End If
End If
End If
Next
appAccess.DoCmd.Close acForm, anAccessObj.Name, acSaveYes
End If
Next
 
The code looks good to me but why don't you iterate through the forms collection instead of going through all the Access objects. Something like:
Code:
dim db as database
dim ctr as container
dim doc as document

set db=currentdb  'or opendatabase whaterver etc.
set ctr=db.containers("Forms")
ctr.Documents.Refresh

for each doc in ctr.documents
'iterate through controls making necessary changes
next doc

set doc=nothing
set ctr=nothing
set db=nothing

I'm taking a wild stab at your problem that because you are changing so many forms that the jet engine cannot keep track of everything without refreshing itself. You may find the above code might run into the same problem.

Hope this helps,
Rewdee
 
I have found why I got the error : as I am modifying another database than the one executing the code, I have to open it, but it's opening in executing mode and so the main form is already opened when I tried to alter it. It doesn't seem to get it into trouble but any next form gets into the error I discribed. So my prbl is getting farther, I have to open the database to alter in design mode...

Thanks for your help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top