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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Importing Objects from CD (D: Drive) 4

Status
Not open for further replies.

Lynne41

Technical User
Jun 17, 2003
29
GB
Hi

I have imported forms in from a CD and now the VBA code doesn't work on any of the command buttons. When I change the form it also won't let me save - it just doesn't do anything (no warning msg)

How can I resolve this and why does this happen?

Thanks
Lynne
 
The forms are probably read-only. Files saved on a CD have the read-only attribute ticked and so this probably is inherited by all the objects within it.

Maybe you could copy the files to the C: drive first, untick the read-ony checkbox and then import from that file.

Hope that sorts it,

Dean :)
 
Hi Dean

Thanks for your reply. I have copied over the the C: drive but there seems to be no check box with the read only option described. I cannot get into the Dbase properties - error message "Access unable to load database properties".

In the past I have just created a new db and imported the objects to the new one but this is the first time the vba hasn't worked. I have compiled the vba too but still no success!!

Lynne
 
Hi,

Sorry I didn't explain it very well. The checkbox is in the Properties of the actual file itself in Windows. So right-click the icon for the database and there should be a read-only attribute tick box.

Dean ;-)
 
Hi Lynne

This is Access 2k, right? [red]Well, A2k has one major bug: You never should import forms containing vba code, it might corrupt your db![/red]

Workaround:
Save all code from the forms into text files (before importing!)
Set the "Contains module" property of the form to "No" (will delete all code)
import the forms
re-assign all code by pasting from the text file and setting Contains module to "Yes"

There is also a Microsoft KB article about this - just forgot which one... ;-)

Sorry that there is no easier way (There might be one, but I've never come across it...)
[wavey]
Andy

Andreas Galambos
EDP / Technical Support Specialist
(andreas.galambos@bowneglobal.de)
HP:
 
I am just modifying some code I just posted in another thread, to automate saving all modules to text files.
Will post shortly.

Dean.
 
This will save all modules to text files (You just need to change the target path in bold):

Public Function SaveCodeModules()

Dim dbs As DAO.Database
Dim strCode As String
Dim vbComp
Dim a
Dim fs

Set dbs = CurrentDb

For Each vbComp In vbe.VBProjects(1).VBComponents
With vbComp
strCode = .CodeModule.Lines(1, .CodeModule.CountOfLines)
Set fs = CreateObject("Scripting.FileSystemObject")
Set a = fs.CreateTextFile("C:\Code\" & .Name & ".txt")
a.Write strCode
a.Close
End With
Next vbComp

Dim frm As Form
Dim rpt As Report
Dim obj As AccessObject

For Each obj In CurrentProject.AllForms
DoCmd.OpenForm obj.Name, acDesign
Set frm = Forms(obj.Name)
frm.HasModule = False
DoCmd.Close acForm, frm.Name, acSaveYes
Next

For Each obj In CurrentProject.AllReports
DoCmd.OpenReport obj.Name, acDesign
Set rpt = Reports(obj.Name)
rpt.HasModule = False
DoCmd.Close acReport, rpt.Name, acSaveYes
Next


End Function

Add the code in red if you want to set the HasModule property of your forms and reports set to No as MakeItSo suggests.

Hope that sorts it,

Dean :)
 
Thanks Dean and Andy - I'll give these a try! What a pain Access 2k has so many bugs!

Lynne
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top